From a337c568486025d22443535b7c047a563bc34373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 16 Apr 2019 14:43:29 +0200 Subject: [PATCH 001/942] Start 3.4 --- .gitignore | 4 +- CMakeLists.txt | 2 +- README.md | 183 +------------------------------------ docs/build.dox | 2 +- docs/main.dox | 2 +- docs/news.dox | 17 ++++ include/GLFW/glfw3.h | 4 +- include/GLFW/glfw3native.h | 2 +- src/cocoa_init.m | 2 +- src/cocoa_joystick.h | 2 +- src/cocoa_joystick.m | 2 +- src/cocoa_monitor.m | 2 +- src/cocoa_platform.h | 2 +- src/cocoa_time.c | 2 +- src/cocoa_window.m | 2 +- src/context.c | 2 +- src/egl_context.c | 2 +- src/egl_context.h | 2 +- src/glfw_config.h.in | 2 +- src/glx_context.c | 2 +- src/glx_context.h | 2 +- src/init.c | 2 +- src/input.c | 2 +- src/internal.h | 2 +- src/linux_joystick.c | 2 +- src/linux_joystick.h | 2 +- src/mappings.h | 2 +- src/mappings.h.in | 2 +- src/monitor.c | 2 +- src/nsgl_context.h | 2 +- src/nsgl_context.m | 2 +- src/null_init.c | 2 +- src/null_joystick.c | 2 +- src/null_joystick.h | 2 +- src/null_monitor.c | 2 +- src/null_platform.h | 2 +- src/null_window.c | 2 +- src/osmesa_context.c | 2 +- src/osmesa_context.h | 2 +- src/posix_thread.c | 2 +- src/posix_thread.h | 2 +- src/posix_time.c | 2 +- src/posix_time.h | 2 +- src/vulkan.c | 2 +- src/wgl_context.c | 2 +- src/wgl_context.h | 2 +- src/win32_init.c | 2 +- src/win32_joystick.c | 2 +- src/win32_joystick.h | 2 +- src/win32_monitor.c | 2 +- src/win32_platform.h | 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_platform.h | 2 +- src/wl_window.c | 2 +- src/x11_init.c | 2 +- src/x11_monitor.c | 2 +- src/x11_platform.h | 2 +- src/x11_window.c | 2 +- src/xkb_unicode.c | 2 +- src/xkb_unicode.h | 2 +- 65 files changed, 83 insertions(+), 247 deletions(-) diff --git a/.gitignore b/.gitignore index 85949926..ff75a013 100644 --- a/.gitignore +++ b/.gitignore @@ -41,11 +41,11 @@ src/wayland-relative-pointer-unstable-v1-protocol.c # Compiled binaries src/libglfw.so src/libglfw.so.3 -src/libglfw.so.3.3 +src/libglfw.so.3.4 src/libglfw.dylib src/libglfw.dylib src/libglfw.3.dylib -src/libglfw.3.3.dylib +src/libglfw.3.4.dylib src/libglfw3.a src/glfw3.lib src/glfw3.dll diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c0f6250..657fd09f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ if (POLICY CMP0054) endif() set(GLFW_VERSION_MAJOR "3") -set(GLFW_VERSION_MINOR "3") +set(GLFW_VERSION_MINOR "4") set(GLFW_VERSION_PATCH "0") set(GLFW_VERSION_EXTRA "") set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}") diff --git a/README.md b/README.md index 27a0b387..3fce2f8c 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/docs/build.dox b/docs/build.dox index 65646aa2..6e8f11f9 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -253,7 +253,7 @@ With a few changes to your `CMakeLists.txt` you can locate the package and target files generated when GLFW is installed. @code{.cmake} -find_package(glfw3 3.3 REQUIRED) +find_package(glfw3 3.4 REQUIRED) @endcode Once GLFW has been added to the project, link against it with the `glfw` target. diff --git a/docs/main.dox b/docs/main.dox index bd563d98..995c2f56 100644 --- a/docs/main.dox +++ b/docs/main.dox @@ -8,7 +8,7 @@ GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan application development. It provides a simple, platform-independent API for creating windows, contexts and surfaces, reading input, handling events, etc. -@ref news_33 list new features, caveats and deprecations. +@ref news_34 list new features, caveats and deprecations. @ref quick_guide is a guide for users new to GLFW. It takes you through how to write a small but complete program. diff --git a/docs/news.dox b/docs/news.dox index da97215c..1e322ca3 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -5,6 +5,23 @@ @tableofcontents +@section news_34 Release notes for version 3.4 + +@subsection features_34 New features in version 3.4 + +@subsection caveats_34 Caveats for version 3.4 + +@subsection deprecations_34 Deprecations in version 3.4 + +@subsection removals_34 Removals in 3.4 + +@subsection symbols_34 New symbols in version 3.4 + +@subsubsection functions_34 New functions in version 3.4 +@subsubsection types_34 New types in version 3.4 +@subsubsection constants_34 New constants in version 3.4 + + @section news_33 Release notes for version 3.3 These are the release notes for version 3.3. For a more detailed view including diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 0521d198..68c28a29 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1,5 +1,5 @@ /************************************************************************* - * GLFW 3.3 - www.glfw.org + * GLFW 3.4 - www.glfw.org * A library for OpenGL, window and input *------------------------------------------------------------------------ * Copyright (c) 2002-2006 Marcus Geelnard @@ -259,7 +259,7 @@ extern "C" { * backward-compatible. * @ingroup init */ -#define GLFW_VERSION_MINOR 3 +#define GLFW_VERSION_MINOR 4 /*! @brief The revision number of the GLFW library. * * This is incremented when a bug fix release is made that does not contain any diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 267e75ca..e680c1e3 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -1,5 +1,5 @@ /************************************************************************* - * GLFW 3.3 - www.glfw.org + * GLFW 3.4 - www.glfw.org * A library for OpenGL, window and input *------------------------------------------------------------------------ * Copyright (c) 2002-2006 Marcus Geelnard diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 41329b37..138695c2 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 macOS - www.glfw.org +// GLFW 3.4 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_joystick.h b/src/cocoa_joystick.h index 0ab81377..ce98221a 100644 --- a/src/cocoa_joystick.h +++ b/src/cocoa_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Cocoa - www.glfw.org +// GLFW 3.4 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2017 Camilla Löwy // diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index db4427d6..a49763b6 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Cocoa - www.glfw.org +// GLFW 3.4 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // Copyright (c) 2012 Torsten Walluhn diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index e327c628..1b47a9df 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 macOS - www.glfw.org +// GLFW 3.4 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 2847f36b..97679732 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 macOS - www.glfw.org +// GLFW 3.4 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_time.c b/src/cocoa_time.c index 3b270351..9d14a1e2 100644 --- a/src/cocoa_time.c +++ b/src/cocoa_time.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 macOS - www.glfw.org +// GLFW 3.4 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2016 Camilla Löwy // diff --git a/src/cocoa_window.m b/src/cocoa_window.m index d6480960..8626f2c8 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 macOS - www.glfw.org +// GLFW 3.4 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/context.c b/src/context.c index 38508522..ce02f4c6 100644 --- a/src/context.c +++ b/src/context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2016 Camilla Löwy diff --git a/src/egl_context.c b/src/egl_context.c index 19525276..7ad11c13 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 EGL - www.glfw.org +// GLFW 3.4 EGL - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/egl_context.h b/src/egl_context.h index 7def043a..e7a3383b 100644 --- a/src/egl_context.h +++ b/src/egl_context.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 EGL - www.glfw.org +// GLFW 3.4 EGL - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index f418c995..018952d2 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2010-2016 Camilla Löwy // diff --git a/src/glx_context.c b/src/glx_context.c index b03a0489..233a24a5 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 GLX - www.glfw.org +// GLFW 3.4 GLX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/glx_context.h b/src/glx_context.h index e63684f3..cff5ddc5 100644 --- a/src/glx_context.h +++ b/src/glx_context.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 GLX - www.glfw.org +// GLFW 3.4 GLX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/init.c b/src/init.c index 3d0f9cf7..eba29af7 100644 --- a/src/init.c +++ b/src/init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2018 Camilla Löwy diff --git a/src/input.c b/src/input.c index a2f42efe..80ed5369 100644 --- a/src/input.c +++ b/src/input.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/internal.h b/src/internal.h index 618507c6..8eda20e5 100644 --- a/src/internal.h +++ b/src/internal.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 42e457f2..97345b21 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Linux - www.glfw.org +// GLFW 3.4 Linux - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/linux_joystick.h b/src/linux_joystick.h index 2eabfa13..7373f130 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Linux - www.glfw.org +// GLFW 3.4 Linux - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/mappings.h b/src/mappings.h index 94a279af..ef76c90f 100644 --- a/src/mappings.h +++ b/src/mappings.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2018 Camilla Löwy // diff --git a/src/mappings.h.in b/src/mappings.h.in index 72460b0d..583e98b2 100644 --- a/src/mappings.h.in +++ b/src/mappings.h.in @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2018 Camilla Löwy // diff --git a/src/monitor.c b/src/monitor.c index d390a1c6..10a00283 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/nsgl_context.h b/src/nsgl_context.h index 2485b180..2c8eb23f 100644 --- a/src/nsgl_context.h +++ b/src/nsgl_context.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 macOS - www.glfw.org +// GLFW 3.4 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/nsgl_context.m b/src/nsgl_context.m index bbbbd36d..0bfeca2d 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 macOS - www.glfw.org +// GLFW 3.4 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/null_init.c b/src/null_init.c index b48477b6..c37ed90f 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016 Google Inc. // Copyright (c) 2016-2017 Camilla Löwy diff --git a/src/null_joystick.c b/src/null_joystick.c index 60180bcb..bcd4b804 100644 --- a/src/null_joystick.c +++ b/src/null_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016-2017 Camilla Löwy // diff --git a/src/null_joystick.h b/src/null_joystick.h index 5a5c5584..2adea420 100644 --- a/src/null_joystick.h +++ b/src/null_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2017 Camilla Löwy // diff --git a/src/null_monitor.c b/src/null_monitor.c index f5cb092f..197ca73e 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016 Google Inc. // Copyright (c) 2016-2019 Camilla Löwy diff --git a/src/null_platform.h b/src/null_platform.h index 7871683e..d844488f 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016 Google Inc. // Copyright (c) 2016-2017 Camilla Löwy diff --git a/src/null_window.c b/src/null_window.c index 67021ab6..bc25de45 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016 Google Inc. // Copyright (c) 2016-2019 Camilla Löwy diff --git a/src/osmesa_context.c b/src/osmesa_context.c index b45bb2e1..6960e7b6 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 OSMesa - www.glfw.org +// GLFW 3.4 OSMesa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016 Google Inc. // Copyright (c) 2016-2017 Camilla Löwy diff --git a/src/osmesa_context.h b/src/osmesa_context.h index 2413188d..a5de0d90 100644 --- a/src/osmesa_context.h +++ b/src/osmesa_context.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 OSMesa - www.glfw.org +// GLFW 3.4 OSMesa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016 Google Inc. // Copyright (c) 2016-2017 Camilla Löwy diff --git a/src/posix_thread.c b/src/posix_thread.c index ff4ea60b..49b318cc 100644 --- a/src/posix_thread.c +++ b/src/posix_thread.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 POSIX - www.glfw.org +// GLFW 3.4 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/posix_thread.h b/src/posix_thread.h index 24452ba0..85ce596c 100644 --- a/src/posix_thread.h +++ b/src/posix_thread.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 POSIX - www.glfw.org +// GLFW 3.4 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/posix_time.c b/src/posix_time.c index 53f856cc..fe7ab768 100644 --- a/src/posix_time.c +++ b/src/posix_time.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 POSIX - www.glfw.org +// GLFW 3.4 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/posix_time.h b/src/posix_time.h index 08cf4fcf..9b59a187 100644 --- a/src/posix_time.h +++ b/src/posix_time.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 POSIX - www.glfw.org +// GLFW 3.4 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/vulkan.c b/src/vulkan.c index cb326732..f5051905 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2018 Camilla Löwy diff --git a/src/wgl_context.c b/src/wgl_context.c index 5b0d09b8..d2a380ea 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 WGL - www.glfw.org +// GLFW 3.4 WGL - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/wgl_context.h b/src/wgl_context.h index fa6605bc..c758c9fe 100644 --- a/src/wgl_context.h +++ b/src/wgl_context.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 WGL - www.glfw.org +// GLFW 3.4 WGL - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2018 Camilla Löwy diff --git a/src/win32_init.c b/src/win32_init.c index e28868f4..9c842de9 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Win32 - www.glfw.org +// GLFW 3.4 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 5c3e87de..a82f8a49 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Win32 - www.glfw.org +// GLFW 3.4 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/win32_joystick.h b/src/win32_joystick.h index 22bcded3..f6384a41 100644 --- a/src/win32_joystick.h +++ b/src/win32_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Win32 - www.glfw.org +// GLFW 3.4 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2017 Camilla Löwy // diff --git a/src/win32_monitor.c b/src/win32_monitor.c index e6875dbc..0553b377 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Win32 - www.glfw.org +// GLFW 3.4 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/win32_platform.h b/src/win32_platform.h index 07e43776..943c445b 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Win32 - www.glfw.org +// GLFW 3.4 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/win32_thread.c b/src/win32_thread.c index 9391fc9b..e9127272 100644 --- a/src/win32_thread.c +++ b/src/win32_thread.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Win32 - www.glfw.org +// GLFW 3.4 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/win32_time.c b/src/win32_time.c index 29670f97..d0311934 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Win32 - www.glfw.org +// GLFW 3.4 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/win32_window.c b/src/win32_window.c index 48b3dd5d..c022b5ba 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Win32 - www.glfw.org +// GLFW 3.4 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/window.c b/src/window.c index cf403dd0..65cabe16 100644 --- a/src/window.c +++ b/src/window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 - www.glfw.org +// GLFW 3.4 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/wl_init.c b/src/wl_init.c index 8a6b918c..7bbfb386 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Wayland - www.glfw.org +// GLFW 3.4 Wayland - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 223c3b8d..0f7a6804 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Wayland - www.glfw.org +// GLFW 3.4 Wayland - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/wl_platform.h b/src/wl_platform.h index 9fef848d..3d281645 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Wayland - www.glfw.org +// GLFW 3.4 Wayland - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/wl_window.c b/src/wl_window.c index 0ae712dd..fe4658cb 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Wayland - www.glfw.org +// GLFW 3.4 Wayland - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/x11_init.c b/src/x11_init.c index dae5b98c..48e3180c 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 X11 - www.glfw.org +// GLFW 3.4 X11 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 1cf0c42b..d94780b2 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 X11 - www.glfw.org +// GLFW 3.4 X11 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/x11_platform.h b/src/x11_platform.h index 3b2b2b22..d6cd92d0 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 X11 - www.glfw.org +// GLFW 3.4 X11 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/x11_window.c b/src/x11_window.c index f66c49b7..1b3f403f 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 X11 - www.glfw.org +// GLFW 3.4 X11 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/xkb_unicode.c b/src/xkb_unicode.c index ad3cc233..1e8f8cd4 100644 --- a/src/xkb_unicode.c +++ b/src/xkb_unicode.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 X11 - www.glfw.org +// GLFW 3.4 X11 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/xkb_unicode.h b/src/xkb_unicode.h index f95e14f1..76d83ffd 100644 --- a/src/xkb_unicode.h +++ b/src/xkb_unicode.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.3 Linux - www.glfw.org +// GLFW 3.4 Linux - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // From 599fb3de348f73134b4e9d2ee5cabc62ca0b84ab Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Fri, 1 Mar 2019 18:46:06 +0100 Subject: [PATCH 002/942] Wayland: Remove wl_shell support This protocol is part of the core Wayland, but it is pretty badly designed and is missing quite a few features, and is in the process of being phased out in compositors. Its support in GLFW requires duplicating pretty much every single window management codepath. This bumps the required compositor versions to the ones which have implemented xdg-shell, approximately two years ago, which seems sensible to me. --- docs/compat.dox | 6 +- include/GLFW/glfw3.h | 7 +- src/wl_init.c | 49 +++++------ src/wl_platform.h | 2 - src/wl_window.c | 205 ++++--------------------------------------- 5 files changed, 40 insertions(+), 229 deletions(-) diff --git a/docs/compat.dox b/docs/compat.dox index 615264b4..25bfc1aa 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -104,11 +104,7 @@ has been configured in the compositor. GLFW uses the [xdg-shell protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/xdg-shell/xdg-shell.xml) to provide better window management. This protocol is part of -wayland-protocols 1.12, and mandatory at build time. If the running compositor -does not support this protocol, the older [wl_shell -interface](https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml#n972) -will be used instead. This will result in a worse integration with the -desktop, especially on tiling compositors. +wayland-protocols 1.12, and mandatory at build time. GLFW uses the [relative pointer protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/unstable/relative-pointer/relative-pointer-unstable-v1.xml) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 68c28a29..a61ec83f 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3089,8 +3089,8 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland There is no concept of iconification in wl_shell, this - * function will emit @ref GLFW_PLATFORM_ERROR when using this deprecated + * @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t + * be able to restore it. This is a design decision of the xdg-shell * protocol. * * @thread_safety This function must only be called from the main thread. @@ -3625,9 +3625,6 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @wayland The wl_shell protocol has no concept of iconification, - * this callback will never be called when using this deprecated protocol. - * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_iconify diff --git a/src/wl_init.c b/src/wl_init.c index 7bbfb386..36b66c29 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -237,9 +237,7 @@ static void pointerHandleButton(void* data, { _GLFWwindow* window = _glfw.wl.pointerFocus; int glfwButton; - - // Both xdg-shell and wl_shell use the same values. - uint32_t edges = WL_SHELL_SURFACE_RESIZE_NONE; + uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; if (!window) return; @@ -251,46 +249,39 @@ static void pointerHandleButton(void* data, break; case topDecoration: if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) - edges = WL_SHELL_SURFACE_RESIZE_TOP; + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; else { - if (window->wl.xdg.toplevel) - xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); - else - wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, serial); + xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); } break; case leftDecoration: if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) - edges = WL_SHELL_SURFACE_RESIZE_TOP_LEFT; + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; else - edges = WL_SHELL_SURFACE_RESIZE_LEFT; + edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; break; case rightDecoration: if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) - edges = WL_SHELL_SURFACE_RESIZE_TOP_RIGHT; + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; else - edges = WL_SHELL_SURFACE_RESIZE_RIGHT; + edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; break; case bottomDecoration: if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH) - edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT; + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH) - edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT; + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; else - edges = WL_SHELL_SURFACE_RESIZE_BOTTOM; + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; break; default: assert(0); } - if (edges != WL_SHELL_SURFACE_RESIZE_NONE) + if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) { - if (window->wl.xdg.toplevel) - xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, - serial, edges); - else - wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat, - serial, edges); + xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, + serial, edges); } } else if (button == BTN_RIGHT) @@ -805,11 +796,6 @@ static void registryHandleGlobal(void* data, _glfw.wl.shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); } - else if (strcmp(interface, "wl_shell") == 0) - { - _glfw.wl.shell = - wl_registry_bind(registry, name, &wl_shell_interface, 1); - } else if (strcmp(interface, "wl_output") == 0) { _glfwAddOutputWayland(name, version); @@ -1164,6 +1150,13 @@ int _glfwPlatformInit(void) if (_glfw.wl.seatVersion >= 4) _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); + if (!_glfw.wl.wmBase) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to find xdg-shell in your compositor"); + return GLFW_FALSE; + } + if (_glfw.wl.pointer && _glfw.wl.shm) { cursorTheme = getenv("XCURSOR_THEME"); @@ -1257,8 +1250,6 @@ void _glfwPlatformTerminate(void) wl_compositor_destroy(_glfw.wl.compositor); if (_glfw.wl.shm) wl_shm_destroy(_glfw.wl.shm); - if (_glfw.wl.shell) - wl_shell_destroy(_glfw.wl.shell); if (_glfw.wl.viewporter) wp_viewporter_destroy(_glfw.wl.viewporter); if (_glfw.wl.decorationManager) diff --git a/src/wl_platform.h b/src/wl_platform.h index 3d281645..13f4ab31 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -180,7 +180,6 @@ typedef struct _GLFWwindowWayland GLFWbool transparent; struct wl_surface* surface; struct wl_egl_window* native; - struct wl_shell_surface* shellSurface; struct wl_callback* callback; struct { @@ -227,7 +226,6 @@ typedef struct _GLFWlibraryWayland struct wl_registry* registry; struct wl_compositor* compositor; struct wl_subcompositor* subcompositor; - struct wl_shell* shell; struct wl_shm* shm; struct wl_seat* seat; struct wl_pointer* pointer; diff --git a/src/wl_window.c b/src/wl_window.c index fe4658cb..9c645fab 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -39,72 +39,6 @@ #include -static void shellSurfaceHandlePing(void* data, - struct wl_shell_surface* shellSurface, - uint32_t serial) -{ - wl_shell_surface_pong(shellSurface, serial); -} - -static void shellSurfaceHandleConfigure(void* data, - struct wl_shell_surface* shellSurface, - uint32_t edges, - int32_t width, - int32_t height) -{ - _GLFWwindow* window = data; - float aspectRatio; - float targetRatio; - - if (!window->monitor) - { - if (_glfw.wl.viewporter && window->decorated) - { - width -= _GLFW_DECORATION_HORIZONTAL; - height -= _GLFW_DECORATION_VERTICAL; - } - if (width < 1) - width = 1; - if (height < 1) - height = 1; - - if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE) - { - aspectRatio = (float)width / (float)height; - targetRatio = (float)window->numer / (float)window->denom; - if (aspectRatio < targetRatio) - height = width / targetRatio; - else if (aspectRatio > targetRatio) - width = height * targetRatio; - } - - if (window->minwidth != GLFW_DONT_CARE && width < window->minwidth) - width = window->minwidth; - else if (window->maxwidth != GLFW_DONT_CARE && width > window->maxwidth) - width = window->maxwidth; - - if (window->minheight != GLFW_DONT_CARE && height < window->minheight) - height = window->minheight; - else if (window->maxheight != GLFW_DONT_CARE && height > window->maxheight) - height = window->maxheight; - } - - _glfwInputWindowSize(window, width, height); - _glfwPlatformSetWindowSize(window, width, height); - _glfwInputWindowDamage(window); -} - -static void shellSurfaceHandlePopupDone(void* data, - struct wl_shell_surface* shellSurface) -{ -} - -static const struct wl_shell_surface_listener shellSurfaceListener = { - shellSurfaceHandlePing, - shellSurfaceHandleConfigure, - shellSurfaceHandlePopupDone -}; - static int createTmpfileCloexec(char* tmpname) { int fd; @@ -529,66 +463,11 @@ static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, window->wl.xdg.toplevel, monitor->wl.output); } - else if (window->wl.shellSurface) - { - wl_shell_surface_set_fullscreen( - window->wl.shellSurface, - WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, - refreshRate * 1000, // Convert Hz to mHz. - monitor->wl.output); - } setIdleInhibitor(window, GLFW_TRUE); if (!window->wl.decorations.serverSide) destroyDecorations(window); } -static GLFWbool createShellSurface(_GLFWwindow* window) -{ - if (!_glfw.wl.shell) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: wl_shell protocol not available"); - return GLFW_FALSE; - } - - window->wl.shellSurface = wl_shell_get_shell_surface(_glfw.wl.shell, - window->wl.surface); - if (!window->wl.shellSurface) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Shell surface creation failed"); - return GLFW_FALSE; - } - - wl_shell_surface_add_listener(window->wl.shellSurface, - &shellSurfaceListener, - window); - - if (window->wl.title) - wl_shell_surface_set_title(window->wl.shellSurface, window->wl.title); - - if (window->monitor) - { - setFullscreen(window, window->monitor, 0); - } - else if (window->wl.maximized) - { - wl_shell_surface_set_maximized(window->wl.shellSurface, NULL); - setIdleInhibitor(window, GLFW_FALSE); - createDecorations(window); - } - else - { - wl_shell_surface_set_toplevel(window->wl.shellSurface); - setIdleInhibitor(window, GLFW_FALSE); - createDecorations(window); - } - - wl_surface_commit(window->wl.surface); - - return GLFW_TRUE; -} - static void xdgToplevelHandleConfigure(void* data, struct xdg_toplevel* toplevel, int32_t width, @@ -949,16 +828,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (wndconfig->visible) { - if (_glfw.wl.wmBase) - { - if (!createXdgSurface(window)) - return GLFW_FALSE; - } - else - { - if (!createShellSurface(window)) - return GLFW_FALSE; - } + if (!createXdgSurface(window)) + return GLFW_FALSE; window->wl.visible = GLFW_TRUE; } @@ -966,7 +837,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, { window->wl.xdg.surface = NULL; window->wl.xdg.toplevel = NULL; - window->wl.shellSurface = NULL; window->wl.visible = GLFW_FALSE; } @@ -1008,9 +878,6 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) if (window->wl.native) wl_egl_window_destroy(window->wl.native); - if (window->wl.shellSurface) - wl_shell_surface_destroy(window->wl.shellSurface); - if (window->wl.xdg.toplevel) xdg_toplevel_destroy(window->wl.xdg.toplevel); @@ -1031,8 +898,6 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) window->wl.title = _glfw_strdup(title); if (window->wl.xdg.toplevel) xdg_toplevel_set_title(window->wl.xdg.toplevel, title); - else if (window->wl.shellSurface) - wl_shell_surface_set_title(window->wl.shellSurface, title); } void _glfwPlatformSetWindowIcon(_GLFWwindow* window, @@ -1078,23 +943,15 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight) { - if (_glfw.wl.wmBase) + if (window->wl.xdg.toplevel) { - if (window->wl.xdg.toplevel) - { - if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE) - minwidth = minheight = 0; - if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE) - maxwidth = maxheight = 0; - xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight); - xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight); - wl_surface_commit(window->wl.surface); - } - } - else - { - // TODO: find out how to trigger a resize. - // The actual limits are checked in the wl_shell_surface::configure handler. + if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE) + minwidth = minheight = 0; + if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE) + maxwidth = maxheight = 0; + xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight); + xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight); + wl_surface_commit(window->wl.surface); } } @@ -1102,7 +959,7 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom) { // TODO: find out how to trigger a resize. - // The actual limits are checked in the wl_shell_surface::configure handler. + // The actual limits are checked in the xdg_toplevel::configure handler. } void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, @@ -1141,16 +998,8 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, void _glfwPlatformIconifyWindow(_GLFWwindow* window) { - if (_glfw.wl.wmBase) - { - if (window->wl.xdg.toplevel) - xdg_toplevel_set_minimized(window->wl.xdg.toplevel); - } - else - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Iconify window not supported on wl_shell"); - } + if (window->wl.xdg.toplevel) + xdg_toplevel_set_minimized(window->wl.xdg.toplevel); } void _glfwPlatformRestoreWindow(_GLFWwindow* window) @@ -1162,12 +1011,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) if (window->wl.maximized) xdg_toplevel_unset_maximized(window->wl.xdg.toplevel); // There is no way to unset minimized, or even to know if we are - // minimized, so there is nothing to do here. - } - else if (window->wl.shellSurface) - { - if (window->monitor || window->wl.maximized) - wl_shell_surface_set_toplevel(window->wl.shellSurface); + // minimized, so there is nothing to do in this case. } _glfwInputWindowMonitor(window, NULL); window->wl.maximized = GLFW_FALSE; @@ -1179,11 +1023,6 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window) { xdg_toplevel_set_maximized(window->wl.xdg.toplevel); } - else if (window->wl.shellSurface) - { - // Let the compositor select the best output. - wl_shell_surface_set_maximized(window->wl.shellSurface, NULL); - } window->wl.maximized = GLFW_TRUE; } @@ -1191,10 +1030,7 @@ void _glfwPlatformShowWindow(_GLFWwindow* window) { if (!window->wl.visible) { - if (_glfw.wl.wmBase) - createXdgSurface(window); - else if (!window->wl.shellSurface) - createShellSurface(window); + createXdgSurface(window); window->wl.visible = GLFW_TRUE; } } @@ -1208,11 +1044,6 @@ void _glfwPlatformHideWindow(_GLFWwindow* window) window->wl.xdg.toplevel = NULL; window->wl.xdg.surface = NULL; } - else if (window->wl.shellSurface) - { - wl_shell_surface_destroy(window->wl.shellSurface); - window->wl.shellSurface = NULL; - } window->wl.visible = GLFW_FALSE; } @@ -1243,8 +1074,6 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, { if (window->wl.xdg.toplevel) xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel); - else if (window->wl.shellSurface) - wl_shell_surface_set_toplevel(window->wl.shellSurface); setIdleInhibitor(window, GLFW_FALSE); if (!_glfw.wl.decorationManager) createDecorations(window); @@ -1259,8 +1088,8 @@ int _glfwPlatformWindowFocused(_GLFWwindow* window) int _glfwPlatformWindowIconified(_GLFWwindow* window) { - // wl_shell doesn't have any iconified concept, and xdg-shell doesn’t give - // any way to request whether a surface is iconified. + // xdg-shell doesn’t give any way to request whether a surface is + // iconified. return GLFW_FALSE; } From ff7d42a55e79bcf526dda829732a18cf8a01a70e 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 003/942] 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 --- .travis.yml | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 804b8647..a5ee5b42 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 be71147ad51b91a7c5b43f75b9e20fa304fa4752 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 004/942] Documentation work The monitor content scale was missing from the monitor properties paragraph. --- docs/monitor.dox | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/monitor.dox b/docs/monitor.dox index a5a7db76..86eb4540 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 15af302f77f7c83a869bdfc7ce9abdeeb6231854 Mon Sep 17 00:00:00 2001 From: Konstantin Podsvirov Date: Thu, 18 Apr 2019 19:50:48 +0300 Subject: [PATCH 005/942] Fix use of absolute path in INSTALL_INTERFACE Closes #1470. --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0913579b..050ee9e0 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 42a3e4434f27c2afd98ab8e51e9bec09d837843d 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 006/942] Update changelog and add credit --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3fce2f8c..017cd5fc 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 090b16bfae282606472f876d6b2fd23fa28e1564 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 007/942] X11: Fix CMake not checking for XInput2 headers Fixes #1480. --- CMakeLists.txt | 8 +++++++- README.md | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 657fd09f..a72f8bc3 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 017cd5fc..3277985c 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 5c5963f1c07e10e344370dbae352683542eab044 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 008/942] 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. --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a72f8bc3..169b1a0a 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 a255e7ace6a1bbdd879df11916b0273ac207cffb 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 009/942] 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). --- 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 169b1a0a..3c2d1798 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0) -project(GLFW C) +project(GLFW VERSION 3.4.0 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 "4") -set(GLFW_VERSION_PATCH "0") -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 27ed92c4..7a0056df 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 98da2cd7..e0a9c2d6 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 050ee9e0..1928670e 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 87423e1a..f74298d4 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 97da4684..7e944668 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 cd290f767fbf572bd2a9b5b79f45e2d4f112802c 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 010/942] Use CMakeDependentOption for dependent options This replaces the earlier manual logic for dependent CMake options with the cmake_dependent_option function from CMakeDependentOption. --- CMakeLists.txt | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c2d1798..d6b6aab0 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) +include(CMakeDependentOption) -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() +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 8ee589e43bcca6e4e3517f245996b73ebdc194eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 8 May 2019 19:04:21 +0200 Subject: [PATCH 011/942] Disable examples and tests when a subproject This changes the default value of the GLFW_BUILD_EXAMPLES and GLFW_BUILD_TESTS CMake options to false when GLFW is being added as a subdirectory by another CMake project. If you want the previous behavior, force these options to true before adding the GLFW subdirectory: set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE) add_subdirectory(path/to/glfw) Doing this is backward compatible with earlier versions of GLFW. The GLFW_BUILD_DOCS option is left enabled as it also requires Doxygen to have any effect, is quicker to build and is more likely to be useful when GLFW is a subproject. --- CMakeLists.txt | 8 ++++++-- README.md | 1 + docs/build.dox | 14 ++------------ docs/compile.dox | 6 ++++-- docs/news.dox | 14 ++++++++++++++ 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6b6aab0..e393a144 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,9 +10,13 @@ endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) +if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + set(GLFW_STANDALONE TRUE) +endif() + option(BUILD_SHARED_LIBS "Build shared libraries" OFF) -option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON) -option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) +option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" GLFW_STANDALONE) +option(GLFW_BUILD_TESTS "Build the GLFW test programs" GLFW_STANDALONE) option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON) option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF) diff --git a/README.md b/README.md index 3277985c..78523eeb 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ information on what to include when reporting a bug. ## Changelog + - Disabled tests and examples by default when built as a CMake subdirectory - 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) diff --git a/docs/build.dox b/docs/build.dox index 6e8f11f9..127c9f06 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -186,18 +186,8 @@ build_link_cmake_package. With a few changes to your `CMakeLists.txt` you can have the GLFW source tree built along with your application. -When including GLFW as part of your build, you probably don't want to build the -GLFW tests, examples and documentation. To disable these, set the corresponding -cache variables before adding the GLFW source tree. - -@code -set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE) -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 and the necessary cache variables to your project. @code{.cmake} add_subdirectory(path/to/glfw) diff --git a/docs/compile.dox b/docs/compile.dox index 8a4fb583..271cee4d 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -212,11 +212,13 @@ library or as a DLL / shared library / dynamic library. @anchor GLFW_BUILD_EXAMPLES __GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built -along with the library. +along with the library. This is enabled by default unless GLFW is being built +as a sub-project. @anchor GLFW_BUILD_TESTS __GLFW_BUILD_TESTS__ determines whether the GLFW test programs are -built along with the library. +built along with the library. This is enabled by default unless GLFW is being +built as a sub-project. @anchor GLFW_BUILD_DOCS __GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along diff --git a/docs/news.dox b/docs/news.dox index 1e322ca3..f551bb94 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -11,6 +11,20 @@ @subsection caveats_34 Caveats for version 3.4 +@subsubsection standalone_34 Tests and examples are disabled when built as a sub-project + +GLFW now does not build the tests and examples when it is added as +a subdirectory of another CMake project. To enable these, set the @ref +GLFW_BUILD_TESTS and @ref GLFW_BUILD_EXAMPLES cache variables before adding the +GLFW subdirectory. + +@code{.cmake} +set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE) +set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE) +add_subdirectory(path/to/glfw) +@endcode + + @subsection deprecations_34 Deprecations in version 3.4 @subsection removals_34 Removals in 3.4 From c0eabc594f71fb44e0fb9d5378fc7a5304f1b868 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 012/942] Add descriptive names for Travis CI jobs --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index a5ee5b42..864869dd 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 7dc36dd7da89abeda5181b6506f79842f813a296 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 013/942] Format Travis CI inline script for readability --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 864869dd..0096210a 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 535491c4f39a272d26b8c53b2d4e3b6de6f53531 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 014/942] 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. --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0096210a..3033fc51 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 0ccb690853e29ae38317d762f9deaa37ba101f4b 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 015/942] Add stable release branch to CI --- .appveyor.yml | 1 + .travis.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index 4a002500..f8aaf42d 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 3033fc51..9b37ebfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ branches: only: - ci - master + - 3.3-stable matrix: include: - os: linux From ceb16cb5f11b078010a669bab817d8927f8a99b7 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 016/942] 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. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e393a144..ac34c6ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,7 +222,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() @@ -230,7 +230,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 57bf6b2f75e46369e83b6d727541991533b1dc2d 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 017/942] Add credit Related to #1480. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 78523eeb..920a0709 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,7 @@ skills. - Lucas Hinderberger - Paul Holden - Warren Hu + - Charles Huber - IntellectualKitty - Aaron Jacobs - Erik S. V. Jansson From 0b01d850ed00abf65ede29da46ad28ca5dbf8081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 20:51:50 +0200 Subject: [PATCH 018/942] NSGL: Remove enforcement of forward-compatible flag This sharp corner should have been addressed a long time ago. --- README.md | 1 + src/nsgl_context.m | 7 ------- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index 920a0709..fc5af9d0 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,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) + - [NSGL] Removed enforcement of forward-compatible flag for core contexts ## Contact diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 0bfeca2d..b55dd6d6 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -194,13 +194,6 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, "NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 but may support 3.2 and above"); return GLFW_FALSE; } - - if (!ctxconfig->forward || ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE) - { - _glfwInputError(GLFW_VERSION_UNAVAILABLE, - "NSGL: The targeted version of macOS only supports forward-compatible core profile contexts for OpenGL 3.2 and above"); - return GLFW_FALSE; - } } // Context robustness modes (GL_KHR_robustness) are not yet supported by From 700d1f28d8f0f55b8f17a979288c6916267e9b9d 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 019/942] Add Vulkan 1.1 support to glfwinfo --- tests/glfwinfo.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 3bd6f23b..618d9a27 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 fa025d8f8077060650cbc3ebc2bce015338d837d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 19:10:35 +0200 Subject: [PATCH 020/942] Convert glfwinfo to C99 --- tests/glfwinfo.c | 91 +++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 52 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 618d9a27..72857475 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "getopt.h" @@ -175,22 +176,19 @@ static const char* get_strategy_name_glfw(int strategy) static void list_context_extensions(int client, int major, int minor) { - int i; - GLint count; - const GLubyte* extensions; - printf("%s context extensions:\n", get_api_name(client)); if (client == GLFW_OPENGL_API && major > 2) { + GLint count; glGetIntegerv(GL_NUM_EXTENSIONS, &count); - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) printf(" %s\n", (const char*) glGetStringi(GL_EXTENSIONS, i)); } else { - extensions = glGetString(GL_EXTENSIONS); + const GLubyte* extensions = glGetString(GL_EXTENSIONS); while (*extensions != '\0') { putchar(' '); @@ -211,15 +209,13 @@ static void list_context_extensions(int client, int major, int minor) static void list_vulkan_instance_extensions(void) { - uint32_t i, ep_count = 0; - VkExtensionProperties* ep; - printf("Vulkan instance extensions:\n"); + uint32_t ep_count; if (vkEnumerateInstanceExtensionProperties(NULL, &ep_count, NULL) != VK_SUCCESS) return; - ep = calloc(ep_count, sizeof(VkExtensionProperties)); + VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties)); if (vkEnumerateInstanceExtensionProperties(NULL, &ep_count, ep) != VK_SUCCESS) { @@ -227,7 +223,7 @@ static void list_vulkan_instance_extensions(void) return; } - for (i = 0; i < ep_count; i++) + for (uint32_t i = 0; i < ep_count; i++) printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion); free(ep); @@ -235,15 +231,13 @@ static void list_vulkan_instance_extensions(void) static void list_vulkan_instance_layers(void) { - uint32_t i, lp_count = 0; - VkLayerProperties* lp; - printf("Vulkan instance layers:\n"); + uint32_t lp_count; if (vkEnumerateInstanceLayerProperties(&lp_count, NULL) != VK_SUCCESS) return; - lp = calloc(lp_count, sizeof(VkLayerProperties)); + VkLayerProperties* lp = calloc(lp_count, sizeof(VkLayerProperties)); if (vkEnumerateInstanceLayerProperties(&lp_count, lp) != VK_SUCCESS) { @@ -251,7 +245,7 @@ static void list_vulkan_instance_layers(void) return; } - for (i = 0; i < lp_count; i++) + for (uint32_t i = 0; i < lp_count; i++) { printf(" %s (v%u) \"%s\"\n", lp[i].layerName, @@ -264,15 +258,13 @@ static void list_vulkan_instance_layers(void) static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice device) { - uint32_t i, ep_count; - VkExtensionProperties* ep; - printf("Vulkan device extensions:\n"); + uint32_t ep_count; if (vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, NULL) != VK_SUCCESS) return; - ep = calloc(ep_count, sizeof(VkExtensionProperties)); + VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties)); if (vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, ep) != VK_SUCCESS) { @@ -280,7 +272,7 @@ static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice return; } - for (i = 0; i < ep_count; i++) + for (uint32_t i = 0; i < ep_count; i++) printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion); free(ep); @@ -288,15 +280,13 @@ static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice device) { - uint32_t i, lp_count; - VkLayerProperties* lp; - printf("Vulkan device layers:\n"); + uint32_t lp_count; if (vkEnumerateDeviceLayerProperties(device, &lp_count, NULL) != VK_SUCCESS) return; - lp = calloc(lp_count, sizeof(VkLayerProperties)); + VkLayerProperties* lp = calloc(lp_count, sizeof(VkLayerProperties)); if (vkEnumerateDeviceLayerProperties(device, &lp_count, lp) != VK_SUCCESS) { @@ -304,7 +294,7 @@ static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice devi return; } - for (i = 0; i < lp_count; i++) + for (uint32_t i = 0; i < lp_count; i++) { printf(" %s (v%u) \"%s\"\n", lp[i].layerName, @@ -352,11 +342,8 @@ static GLADapiproc glad_vulkan_callback(const char* name, void* user) int main(int argc, char** argv) { - int ch, client, major, minor, revision, profile; - GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits; - int list_extensions = GLFW_FALSE, list_layers = GLFW_FALSE; - GLenum error; - GLFWwindow* window; + int ch; + bool list_extensions = false, list_layers = false; enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG, FORWARD, HELP, EXTENSIONS, LAYERS, MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION, @@ -623,7 +610,7 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); - window = glfwCreateWindow(200, 200, "Version", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(200, 200, "Version", NULL, NULL); if (!window) { glfwTerminate(); @@ -633,17 +620,17 @@ int main(int argc, char** argv) glfwMakeContextCurrent(window); gladLoadGL(glfwGetProcAddress); - error = glGetError(); + const GLenum error = glGetError(); if (error != GL_NO_ERROR) printf("*** OpenGL error after make current: 0x%08x ***\n", error); // Report client API version - client = glfwGetWindowAttrib(window, GLFW_CLIENT_API); - major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR); - minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR); - revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION); - profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE); + const int client = glfwGetWindowAttrib(window, GLFW_CLIENT_API); + const int major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR); + const int minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR); + const int revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION); + const int profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE); printf("%s context version string: \"%s\"\n", get_api_name(client), @@ -735,6 +722,8 @@ int main(int argc, char** argv) printf("%s framebuffer:\n", get_api_name(client)); + GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits; + if (client == GLFW_OPENGL_API && profile == GLFW_OPENGL_CORE_PROFILE) { glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, @@ -809,16 +798,10 @@ 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}; - VkInstanceCreateInfo ici = {0}; - VkInstance instance; - VkPhysicalDevice* pd; - gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL); + uint32_t loader_version = VK_API_VERSION_1_0; + if (vkEnumerateInstanceVersion) { uint32_t version; @@ -830,12 +813,13 @@ int main(int argc, char** argv) VK_VERSION_MAJOR(loader_version), VK_VERSION_MINOR(loader_version)); - re = glfwGetRequiredInstanceExtensions(&re_count); + uint32_t re_count; + const char** re = glfwGetRequiredInstanceExtensions(&re_count); printf("Vulkan required instance extensions:"); if (re) { - for (i = 0; i < re_count; i++) + for (uint32_t i = 0; i < re_count; i++) printf(" %s", re[i]); putchar('\n'); } @@ -848,7 +832,7 @@ int main(int argc, char** argv) if (list_layers) list_vulkan_instance_layers(); - ai.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; + VkApplicationInfo ai = { VK_STRUCTURE_TYPE_APPLICATION_INFO }; ai.pApplicationName = "glfwinfo"; ai.applicationVersion = VK_MAKE_VERSION(GLFW_VERSION_MAJOR, GLFW_VERSION_MINOR, @@ -859,11 +843,13 @@ int main(int argc, char** argv) else ai.apiVersion = VK_API_VERSION_1_0; - ici.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + VkInstanceCreateInfo ici = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO }; ici.pApplicationInfo = &ai; ici.enabledExtensionCount = re_count; ici.ppEnabledExtensionNames = re; + VkInstance instance = VK_NULL_HANDLE; + if (vkCreateInstance(&ici, NULL, &instance) != VK_SUCCESS) { glfwTerminate(); @@ -872,6 +858,7 @@ int main(int argc, char** argv) gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, instance); + uint32_t pd_count; if (vkEnumeratePhysicalDevices(instance, &pd_count, NULL) != VK_SUCCESS) { vkDestroyInstance(instance, NULL); @@ -879,7 +866,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - pd = calloc(pd_count, sizeof(VkPhysicalDevice)); + VkPhysicalDevice* pd = calloc(pd_count, sizeof(VkPhysicalDevice)); if (vkEnumeratePhysicalDevices(instance, &pd_count, pd) != VK_SUCCESS) { @@ -889,7 +876,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - for (i = 0; i < pd_count; i++) + for (uint32_t i = 0; i < pd_count; i++) { VkPhysicalDeviceProperties pdp; From 144c98bcb36ed4173a4c16f437914f46af55a284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 19:26:16 +0200 Subject: [PATCH 021/942] Simplify glfwinfo Vulkan enumerations --- tests/glfwinfo.c | 61 ++++++++---------------------------------------- 1 file changed, 10 insertions(+), 51 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 72857475..4cc6f319 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -212,16 +212,9 @@ static void list_vulkan_instance_extensions(void) printf("Vulkan instance extensions:\n"); uint32_t ep_count; - if (vkEnumerateInstanceExtensionProperties(NULL, &ep_count, NULL) != VK_SUCCESS) - return; - + vkEnumerateInstanceExtensionProperties(NULL, &ep_count, NULL); VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties)); - - if (vkEnumerateInstanceExtensionProperties(NULL, &ep_count, ep) != VK_SUCCESS) - { - free(ep); - return; - } + vkEnumerateInstanceExtensionProperties(NULL, &ep_count, ep); for (uint32_t i = 0; i < ep_count; i++) printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion); @@ -234,16 +227,9 @@ static void list_vulkan_instance_layers(void) printf("Vulkan instance layers:\n"); uint32_t lp_count; - if (vkEnumerateInstanceLayerProperties(&lp_count, NULL) != VK_SUCCESS) - return; - + vkEnumerateInstanceLayerProperties(&lp_count, NULL); VkLayerProperties* lp = calloc(lp_count, sizeof(VkLayerProperties)); - - if (vkEnumerateInstanceLayerProperties(&lp_count, lp) != VK_SUCCESS) - { - free(lp); - return; - } + vkEnumerateInstanceLayerProperties(&lp_count, lp); for (uint32_t i = 0; i < lp_count; i++) { @@ -261,16 +247,9 @@ static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice printf("Vulkan device extensions:\n"); uint32_t ep_count; - if (vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, NULL) != VK_SUCCESS) - return; - + vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, NULL); VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties)); - - if (vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, ep) != VK_SUCCESS) - { - free(ep); - return; - } + vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, ep); for (uint32_t i = 0; i < ep_count; i++) printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion); @@ -283,16 +262,9 @@ static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice devi printf("Vulkan device layers:\n"); uint32_t lp_count; - if (vkEnumerateDeviceLayerProperties(device, &lp_count, NULL) != VK_SUCCESS) - return; - + vkEnumerateDeviceLayerProperties(device, &lp_count, NULL); VkLayerProperties* lp = calloc(lp_count, sizeof(VkLayerProperties)); - - if (vkEnumerateDeviceLayerProperties(device, &lp_count, lp) != VK_SUCCESS) - { - free(lp); - return; - } + vkEnumerateDeviceLayerProperties(device, &lp_count, lp); for (uint32_t i = 0; i < lp_count; i++) { @@ -859,22 +831,9 @@ int main(int argc, char** argv) gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, instance); uint32_t pd_count; - if (vkEnumeratePhysicalDevices(instance, &pd_count, NULL) != VK_SUCCESS) - { - vkDestroyInstance(instance, NULL); - glfwTerminate(); - exit(EXIT_FAILURE); - } - + vkEnumeratePhysicalDevices(instance, &pd_count, NULL); VkPhysicalDevice* pd = calloc(pd_count, sizeof(VkPhysicalDevice)); - - if (vkEnumeratePhysicalDevices(instance, &pd_count, pd) != VK_SUCCESS) - { - free(pd); - vkDestroyInstance(instance, NULL); - glfwTerminate(); - exit(EXIT_FAILURE); - } + vkEnumeratePhysicalDevices(instance, &pd_count, pd); for (uint32_t i = 0; i < pd_count; i++) { From c415c71947b090590b206f48ba3f654bf1d8c184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 19:27:48 +0200 Subject: [PATCH 022/942] Clean up glfwinfo Vulkan version output --- tests/glfwinfo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 4cc6f319..d3a089d7 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -217,7 +217,7 @@ static void list_vulkan_instance_extensions(void) vkEnumerateInstanceExtensionProperties(NULL, &ep_count, ep); for (uint32_t i = 0; i < ep_count; i++) - printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion); + printf(" %s (spec version %u)\n", ep[i].extensionName, ep[i].specVersion); free(ep); } @@ -233,7 +233,7 @@ static void list_vulkan_instance_layers(void) for (uint32_t i = 0; i < lp_count; i++) { - printf(" %s (v%u) \"%s\"\n", + printf(" %s (spec version %u) \"%s\"\n", lp[i].layerName, lp[i].specVersion >> 22, lp[i].description); @@ -252,7 +252,7 @@ static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, ep); for (uint32_t i = 0; i < ep_count; i++) - printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion); + printf(" %s (spec version %u)\n", ep[i].extensionName, ep[i].specVersion); free(ep); } @@ -268,7 +268,7 @@ static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice devi for (uint32_t i = 0; i < lp_count; i++) { - printf(" %s (v%u) \"%s\"\n", + printf(" %s (spec version %u) \"%s\"\n", lp[i].layerName, lp[i].specVersion >> 22, lp[i].description); @@ -841,7 +841,7 @@ int main(int argc, char** argv) vkGetPhysicalDeviceProperties(pd[i], &pdp); - printf("Vulkan %s device: \"%s\" API version %i.%i\n", + printf("Vulkan %s device: \"%s\" (API version %i.%i)\n", get_device_type_name(pdp.deviceType), pdp.deviceName, VK_VERSION_MAJOR(pdp.apiVersion), From f61d0916fda689a01cce70068a45ad7a933e8851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 19:30:40 +0200 Subject: [PATCH 023/942] Convert OpenGL triangle example to C99 --- examples/simple.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/examples/simple.c b/examples/simple.c index 9b632ea3..474a85f9 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -76,10 +76,6 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, int main(void) { - GLFWwindow* window; - GLuint vertex_buffer, vertex_shader, fragment_shader, program; - GLint mvp_location, vpos_location, vcol_location; - glfwSetErrorCallback(error_callback); if (!glfwInit()) @@ -88,7 +84,7 @@ int main(void) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); - window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); if (!window) { glfwTerminate(); @@ -103,26 +99,27 @@ int main(void) // NOTE: OpenGL error checks have been omitted for brevity + GLuint vertex_buffer; glGenBuffers(1, &vertex_buffer); glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); - vertex_shader = glCreateShader(GL_VERTEX_SHADER); + const GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL); glCompileShader(vertex_shader); - fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); + const GLuint fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL); glCompileShader(fragment_shader); - program = glCreateProgram(); + const GLuint program = glCreateProgram(); glAttachShader(program, vertex_shader); glAttachShader(program, fragment_shader); glLinkProgram(program); - mvp_location = glGetUniformLocation(program, "MVP"); - vpos_location = glGetAttribLocation(program, "vPos"); - vcol_location = glGetAttribLocation(program, "vCol"); + const GLint mvp_location = glGetUniformLocation(program, "MVP"); + const GLint vpos_location = glGetAttribLocation(program, "vPos"); + const GLint vcol_location = glGetAttribLocation(program, "vCol"); glEnableVertexAttribArray(vpos_location); glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE, @@ -133,16 +130,14 @@ int main(void) while (!glfwWindowShouldClose(window)) { - float ratio; int width, height; - mat4x4 m, p, mvp; - glfwGetFramebufferSize(window, &width, &height); - ratio = width / (float) height; + const float ratio = width / (float) height; glViewport(0, 0, width, height); glClear(GL_COLOR_BUFFER_BIT); + mat4x4 m, p, mvp; mat4x4_identity(m); mat4x4_rotate_Z(m, m, (float) glfwGetTime()); mat4x4_ortho(p, -ratio, ratio, -1.f, 1.f, 1.f, -1.f); From d44bfe02649fa818e229085e090ec8aef18f2e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 21:18:30 +0200 Subject: [PATCH 024/942] Add vertex type and offsetof to OpenGL triangle --- examples/simple.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/simple.c b/examples/simple.c index 474a85f9..428ecd81 100644 --- a/examples/simple.c +++ b/examples/simple.c @@ -30,17 +30,20 @@ #include "linmath.h" #include +#include #include -static const struct +typedef struct Vertex { - float x, y; - float r, g, b; -} vertices[3] = + vec2 pos; + vec3 col; +} Vertex; + +static const Vertex vertices[3] = { - { -0.6f, -0.4f, 1.f, 0.f, 0.f }, - { 0.6f, -0.4f, 0.f, 1.f, 0.f }, - { 0.f, 0.6f, 0.f, 0.f, 1.f } + { { -0.6f, -0.4f }, { 1.f, 0.f, 0.f } }, + { { 0.6f, -0.4f }, { 0.f, 1.f, 0.f } }, + { { 0.f, 0.6f }, { 0.f, 0.f, 1.f } } }; static const char* vertex_shader_text = @@ -123,10 +126,10 @@ int main(void) glEnableVertexAttribArray(vpos_location); glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE, - sizeof(vertices[0]), (void*) 0); + sizeof(Vertex), (void*) offsetof(Vertex, pos)); glEnableVertexAttribArray(vcol_location); glVertexAttribPointer(vcol_location, 3, GL_FLOAT, GL_FALSE, - sizeof(vertices[0]), (void*) (sizeof(float) * 2)); + sizeof(Vertex), (void*) offsetof(Vertex, col)); while (!glfwWindowShouldClose(window)) { From a639d6e635d091fe6e555c4f6d2c3219093a26f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 19:46:22 +0200 Subject: [PATCH 025/942] Rename OpenGL triangle example to triangle-opengl --- .gitignore | 2 +- docs/quick.dox | 15 ++++++++------- examples/CMakeLists.txt | 6 +++--- examples/{simple.c => triangle-opengl.c} | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) rename examples/{simple.c => triangle-opengl.c} (97%) diff --git a/.gitignore b/.gitignore index ff75a013..564eb978 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,7 @@ examples/offscreen examples/particles examples/splitview examples/sharing -examples/simple +examples/triangle-opengl examples/wave tests/*.app tests/*.exe diff --git a/docs/quick.dox b/docs/quick.dox index 14d03de1..1ad9be0f 100644 --- a/docs/quick.dox +++ b/docs/quick.dox @@ -4,7 +4,7 @@ @tableofcontents -This guide takes you through writing a simple application using GLFW 3. The +This guide takes you through writing a small application using GLFW 3. The application will create a window and OpenGL context, render a rotating triangle and exit when the user closes the window or presses _Escape_. This guide will introduce a few of the most commonly used functions, but there are many more. @@ -326,19 +326,20 @@ for example, many kinds of editing tools. @section quick_example Putting it together Now that you know how to initialize GLFW, create a window and poll for -keyboard input, it's possible to create a simple program. +keyboard input, it's possible to create a small program. This program creates a 640 by 480 windowed mode window and starts a loop that clears the screen, renders a triangle and processes events until the user either presses _Escape_ or closes the window. -@snippet simple.c code +@snippet triangle-opengl.c code 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 -Windows, `simple` on Linux or `simple.app` on macOS. +[source package](https://www.glfw.org/download.html) as +`examples/triangle-opengl.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 `triangle-opengl.exe` on Windows, `triangle-opengl` on Linux or +`triangle-opengl.app` on macOS. This tutorial used only a few of the many functions GLFW provides. There are guides for each of the areas covered by GLFW. Each guide will introduce all the diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e0a9c2d6..93b30ed2 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -36,8 +36,8 @@ add_executable(heightmap WIN32 MACOSX_BUNDLE heightmap.c ${ICON} ${GLAD_GL}) add_executable(offscreen offscreen.c ${ICON} ${GLAD_GL}) add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD} ${GETOPT} ${GLAD_GL}) add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${ICON} ${GLAD_GL}) -add_executable(simple WIN32 MACOSX_BUNDLE simple.c ${ICON} ${GLAD_GL}) add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD_GL}) +add_executable(triangle-opengl WIN32 MACOSX_BUNDLE triangle-opengl.c ${ICON} ${GLAD_GL}) add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL}) target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}") @@ -45,7 +45,7 @@ if (RT_LIBRARY) target_link_libraries(particles "${RT_LIBRARY}") endif() -set(WINDOWS_BINARIES boing gears heightmap particles sharing simple splitview wave) +set(WINDOWS_BINARIES boing gears heightmap particles sharing splitview triangle-opengl wave) set(CONSOLE_BINARIES offscreen) set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES @@ -63,7 +63,7 @@ if (APPLE) set_target_properties(heightmap PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Heightmap") set_target_properties(particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles") set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") - set_target_properties(simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple") + set_target_properties(triangle-opengl PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL Triangle") set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView") set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") diff --git a/examples/simple.c b/examples/triangle-opengl.c similarity index 97% rename from examples/simple.c rename to examples/triangle-opengl.c index 428ecd81..67457745 100644 --- a/examples/simple.c +++ b/examples/triangle-opengl.c @@ -1,5 +1,5 @@ //======================================================================== -// Simple GLFW example +// OpenGL triangle example // Copyright (c) Camilla Löwy // // This software is provided 'as-is', without any express or implied @@ -87,7 +87,7 @@ int main(void) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); - GLFWwindow* window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(640, 480, "OpenGL Triangle", NULL, NULL); if (!window) { glfwTerminate(); From e4aba7feaabb78d4845e17e5063f7e22f0628e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 20:59:10 +0200 Subject: [PATCH 026/942] Convert triangle-opengl example to 3.3 core --- docs/quick.dox | 9 +++++++-- examples/triangle-opengl.c | 24 +++++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/docs/quick.dox b/docs/quick.dox index 1ad9be0f..80433371 100644 --- a/docs/quick.dox +++ b/docs/quick.dox @@ -135,9 +135,14 @@ require a minimum OpenGL version by setting the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` hints _before_ creation. If the required minimum version is not supported on the machine, context (and window) creation fails. +You can select the OpenGL profile by setting the `GLFW_OPENGL_PROFILE` hint. +This program uses the core profile as that is the only profile macOS supports +for OpenGL 3.x and 4.x. + @code -glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); -glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); +glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); +glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); +glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); if (!window) { diff --git a/examples/triangle-opengl.c b/examples/triangle-opengl.c index 67457745..cc2ee16f 100644 --- a/examples/triangle-opengl.c +++ b/examples/triangle-opengl.c @@ -47,11 +47,11 @@ static const Vertex vertices[3] = }; static const char* vertex_shader_text = -"#version 110\n" +"#version 330\n" "uniform mat4 MVP;\n" -"attribute vec3 vCol;\n" -"attribute vec2 vPos;\n" -"varying vec3 color;\n" +"in vec3 vCol;\n" +"in vec2 vPos;\n" +"out vec3 color;\n" "void main()\n" "{\n" " gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" @@ -59,11 +59,12 @@ static const char* vertex_shader_text = "}\n"; static const char* fragment_shader_text = -"#version 110\n" -"varying vec3 color;\n" +"#version 330\n" +"in vec3 color;\n" +"out vec4 fragment;\n" "void main()\n" "{\n" -" gl_FragColor = vec4(color, 1.0);\n" +" fragment = vec4(color, 1.0);\n" "}\n"; static void error_callback(int error, const char* description) @@ -84,8 +85,9 @@ int main(void) if (!glfwInit()) exit(EXIT_FAILURE); - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); GLFWwindow* window = glfwCreateWindow(640, 480, "OpenGL Triangle", NULL, NULL); if (!window) @@ -124,6 +126,9 @@ int main(void) const GLint vpos_location = glGetAttribLocation(program, "vPos"); const GLint vcol_location = glGetAttribLocation(program, "vCol"); + GLuint vertex_array; + glGenVertexArrays(1, &vertex_array); + glBindVertexArray(vertex_array); glEnableVertexAttribArray(vpos_location); glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*) offsetof(Vertex, pos)); @@ -148,6 +153,7 @@ int main(void) glUseProgram(program); glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp); + glBindVertexArray(vertex_array); glDrawArrays(GL_TRIANGLES, 0, 3); glfwSwapBuffers(window); From 3cf7645b96c593d74f089069ac2e1c67938efd7f 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 027/942] 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. --- 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 f38e0885..3a9e4a29 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 a61ec83f..b4428857 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 e91d0fc499c1ff68c9050680ed73da61bcec8365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 19 May 2019 21:46:34 +0200 Subject: [PATCH 028/942] Clarify triangle-opengl uniform uniform update The previous way worked as mat4 is an array typedef but this way may be clearer to people new to the linmath header. --- examples/triangle-opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/triangle-opengl.c b/examples/triangle-opengl.c index cc2ee16f..fef7f8fd 100644 --- a/examples/triangle-opengl.c +++ b/examples/triangle-opengl.c @@ -152,7 +152,7 @@ int main(void) mat4x4_mul(mvp, p, m); glUseProgram(program); - glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp); + glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) &mvp); glBindVertexArray(vertex_array); glDrawArrays(GL_TRIANGLES, 0, 3); From feaa5328861d9767d59d4bb60c5553539060cda2 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 029/942] Add missing word --- docs/quick.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quick.dox b/docs/quick.dox index 80433371..17d2679a 100644 --- a/docs/quick.dox +++ b/docs/quick.dox @@ -342,7 +342,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/triangle-opengl.c` and is compiled along with all other examples when -you build GLFW. If you built GLFW from the source package then already have +you build GLFW. If you built GLFW from the source package then you already have this as `triangle-opengl.exe` on Windows, `triangle-opengl` on Linux or `triangle-opengl.app` on macOS. From 56aad76b164be741af21688ea3832093c2069cef 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 030/942] 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. --- 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 138695c2..01c1b319 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 a49763b6..b98f9f67 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 1b47a9df..e9148ff1 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 9d14a1e2..4bf646c8 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 8626f2c8..b1a4d81f 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 ce02f4c6..48311e5f 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 7ad11c13..6a33396f 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 233a24a5..1e1a9da8 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 eba29af7..96feab0c 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 80ed5369..28291750 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 97345b21..2918db55 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 10a00283..4f86cb80 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 b55dd6d6..4e64af1c 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 c37ed90f..20c76dc5 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 bcd4b804..36c18aa2 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 197ca73e..0a7fe064 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 bc25de45..936400d3 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 6960e7b6..70e8675b 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 49b318cc..02361457 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 fe7ab768..301cb958 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 f5051905..6fd0af2c 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 d2a380ea..57457586 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 9c842de9..950a52a3 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 a82f8a49..c19f77c5 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 0553b377..988a3f95 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 e9127272..53b34af2 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 d0311934..721b0d0d 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 c022b5ba..090e6554 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 65cabe16..fa604d01 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 36b66c29..cdbfcf1e 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 0f7a6804..89cdd8ba 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 9c645fab..5c7011fd 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 48e3180c..6ad8a624 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 d94780b2..3efe818d 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 1b3f403f..daede3bc 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 1e8f8cd4..2772ea09 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 3fd4e79adb00b94442e39d3a16ccc73bc34ec8bb 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 031/942] WGL: Fix misplaced block comment --- 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 c758c9fe..92ec1667 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 22a6c02a4c35752a0bf9d58b6bad5151e5006eea 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 032/942] 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. --- 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 57457586..7d5579e0 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 92ec1667..df983e91 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 bb6945a18ad4a33a2d2a0c9874da11e699978ed2 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 033/942] Clarify difference between time and timer in docs --- 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 4c07a818..eb0244a7 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 b4428857..9cedc766 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5066,23 +5066,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 @@ -5093,23 +5096,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 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 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 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 267e06a41e873ee86fbec6763e0932347496347c 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 034/942] Win32: Remove stale comment --- src/win32_window.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/win32_window.c b/src/win32_window.c index 090e6554..1392ed3c 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 d0c3fa900a378ae1accd74cee88a9b0f03c13f6b 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 035/942] Win32: Fix non-client actions for disabled cursor Disabled cursor mode interfered with some non-client actions. --- 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 1392ed3c..b8d0dc3d 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 84ec99bb01b1d1367239d349f97781fd8abaae3a 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 036/942] Remove pointless comments --- 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 1e1a9da8..7ccd1374 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 4e64af1c..14253988 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 7d5579e0..4f9a6ffe 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 e1d9e2ba73a0ee6acfbbd4442eb2b5f7720cd29b 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 037/942] Clarify Doxyfile INPUT value generation --- 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 7a7407a1..df9e2147 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 7a0056df..0eff0b0f 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 98dde03ce1f596b36ff606a5f7388f1ed8383c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 20 May 2019 23:06:22 +0200 Subject: [PATCH 038/942] Fix variable dereferencing --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac34c6ae..20888664 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,8 @@ if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") endif() option(BUILD_SHARED_LIBS "Build shared libraries" OFF) -option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" GLFW_STANDALONE) -option(GLFW_BUILD_TESTS "Build the GLFW test programs" GLFW_STANDALONE) +option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE}) +option(GLFW_BUILD_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE}) option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON) option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF) From 71e6ff386d9a3e0cc7c069be9b0ee1a9ac738647 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 039/942] 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) --- CMakeLists.txt | 4 ++++ README.md | 1 + 2 files changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20888664..04174cd1 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) if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/README.md b/README.md index fc5af9d0..56e5e17a 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,7 @@ skills. - Robin Leffmann - Glenn Lewis - Shane Liesegang + - Anders Lindqvist - Eyal Lotem - Aaron Loucks - Tristam MacDonald From 51bb76c7c3de934b2dd3affcdc297a32e4817835 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 040/942] Improve (?) reference documentation for callbacks --- 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 0eff0b0f..80ac3bd1 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 9cedc766..07345aec 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. * * @thread_safety This function must only be called from the main thread. @@ -3633,7 +3773,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. * @@ -3641,11 +3781,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. @@ -3656,7 +3803,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. * @@ -3664,11 +3811,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. @@ -3679,7 +3833,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. * @@ -3687,11 +3841,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. @@ -3703,7 +3864,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. * @@ -4350,11 +4511,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. @@ -4366,7 +4534,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. * @@ -4386,11 +4554,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. @@ -4402,7 +4577,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. * @@ -4420,11 +4595,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. @@ -4437,7 +4619,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. * @@ -4451,11 +4633,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. @@ -4467,7 +4656,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. * @@ -4477,11 +4666,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. @@ -4492,20 +4688,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. @@ -4516,7 +4719,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. * @@ -4528,11 +4731,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. @@ -4543,12 +4753,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 @@ -4556,11 +4766,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. @@ -4573,7 +4790,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. * @@ -4892,11 +5109,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. @@ -4907,7 +5131,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 c442dfdc..f1dde456 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 9e88199f..17ca7606 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 537ea4ccf1deb7b5e00c3745ab51e82a8c0696dc 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 041/942] 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. --- 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/splitview.c | 1 + examples/triangle-opengl.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 2ffddbd6..ca389086 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 4c7d9a98..292f44b5 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 bd38339a..13a3c1e1 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 4f717cb5..eca37c48 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 29889149..248c8516 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 34936011..4a1a2323 100644 --- a/examples/sharing.c +++ b/examples/sharing.c @@ -24,6 +24,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include diff --git a/examples/splitview.c b/examples/splitview.c index 1e02b778..58eb11ef 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/triangle-opengl.c b/examples/triangle-opengl.c index fef7f8fd..00bc37dd 100644 --- a/examples/triangle-opengl.c +++ b/examples/triangle-opengl.c @@ -25,6 +25,7 @@ //! [code] #include +#define GLFW_INCLUDE_NONE #include #include "linmath.h" diff --git a/examples/wave.c b/examples/wave.c index 32d78c6a..7acb8b92 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 c6093ce5..41454a3c 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 3edadf02..b6288f6a 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 ae87f849..c3877a71 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 f1dde456..ba7f00ab 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 c625447b..aa4c8b78 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 d3a089d7..afc32427 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 301923f7..aa7ee181 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 2224a67e..ff446d2d 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 f6f5befe..269a0c8f 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 17ca7606..8eae021e 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 d35dfe1f..30ce4088 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 45d7df7a..33e2ccc3 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 5c086ec7..47f28b16 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 e077092d..10d22b28 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 8b28d396..17a3f0e4 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 70a93aa9..98294933 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 e025dfaa..bda2560c 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 ca8dc5f9..a5bad342 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 296ee937..6669856f 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -28,6 +28,7 @@ //======================================================================== #include +#define GLFW_INCLUDE_NONE #include #include From d834f01ca43c0f5ddd31b00a7fc2f48abbafa3da 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 042/942] Rename legacy Vulkan triangle program Fixes #1477. --- .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 564eb978..96d5ba3f 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 7e944668..fcc99243 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 2db3b9688da30811c7d92fa9482fd48d8b8382b0 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Fri, 7 Jun 2019 23:35:10 +0200 Subject: [PATCH 043/942] Replace some tabs with spaces I found some tabs where there should be spaces for consistency. Closes #1496. --- 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 e7a3383b..8bfb7db6 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 cff5ddc5..94f07e2e 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 8eda20e5..acdae22d 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 943c445b..6507c872 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 0c6b5056196a409e6aac244c983244211abf13b1 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 044/942] Convert some declarations to C99 style --- 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 e9148ff1..b5ef58c2 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 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) { @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 b1a4d81f..af74d4da 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -612,10 +612,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (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 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; 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 2918db55..1f9b35fe 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 6ad8a624..8dbe53e2 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 3efe818d..0c649580 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 daede3bc..5b45453c 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 fad9896d38922222cdd28608cfc27c3761b3d90b 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 045/942] 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. --- 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 8dbe53e2..9d072ab4 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -371,18 +371,11 @@ static Atom getSupportedAtom(Atom* supportedAtoms, // static void detectEWMH(void) { + // First we read the _NET_SUPPORTING_WM_CHECK property on the root window + 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); - - // Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window 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 + // 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 - Atom* supportedAtoms; - unsigned long atomCount; - - // 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 d6cd92d0..8bdab83f 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 1f508530f0cda2db78404a82fba1b956372e67aa 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 046/942] X11: Let the language initialize XEvent structs --- 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 5b45453c..db7ab19c 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 1d6215726807e73fd21da9a4a09c28aab3111879 Mon Sep 17 00:00:00 2001 From: "A. Tombs" Date: Tue, 28 May 2019 01:24:18 +0100 Subject: [PATCH 047/942] 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. --- 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 b8d0dc3d..24966bf4 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 3262c29440428348e33b746c4783d783b2825228 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 048/942] Cocoa: Cleanup This makes the Cocoa _glfwPlatformSetWindowMonitor consistent with its X11 and Win32 counterparts. --- 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 af74d4da..1674795c 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 3a5e99e59a74aae9cb74dbd1170374aec9ecc6a2 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 049/942] Remove unused function in tearing test --- tests/tearing.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/tearing.c b/tests/tearing.c index 17a3f0e4..17601219 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 e463e85bbab1bd1c805f9a7d733ccd9caa5fa45f Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sat, 8 Jun 2019 00:06:22 +0200 Subject: [PATCH 050/942] Fix typo Closes #1513. --- 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 89cdd8ba..55f62015 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 c6b95e3b07b9c20d9adae2ddebf69706540180de 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 051/942] X11: Fix focus events not being filtered The filter condition had ended up below the action. --- 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 db7ab19c..8f035b84 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 36f90800d8d490b27d4dc2109c07a95a12007327 Mon Sep 17 00:00:00 2001 From: Denis Bernard Date: Thu, 30 May 2019 00:37:26 +0200 Subject: [PATCH 052/942] 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. --- 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 9d072ab4..ae76d36b 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 8bdab83f..dbbe9d1f 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 8f035b84..d4da7c8d 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 d232bcfcdde2435110fcce9d6027db726e57646f 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 053/942] Cleanup Related to #1528. --- 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 d4da7c8d..1398cb70 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 5bea122211a4c537e461f7f473a8d9afbc98af6f 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 054/942] Update changelog Related to #1528. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 56e5e17a..97b013a8 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,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) - [NSGL] Removed enforcement of forward-compatible flag for core contexts From 773f4495f005004ea17fbc4a96b6b1ce758e79d6 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 055/942] 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. --- README.md | 2 ++ include/GLFW/glfw3.h | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 97b013a8..3205c89b 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,8 @@ information on what to include when reporting a bug. - Disabled tests and examples by default when built as a CMake subdirectory - 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 07345aec..ecbfd1d1 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 62b7fe831179428c3fa1d7939d48562772ee5647 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 056/942] Cleanup --- 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 ecbfd1d1..46f9ad4b 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 84b13113ed5e16aa29a0f5b4a0e95487081184a3 Mon Sep 17 00:00:00 2001 From: Lukas Zanner Date: Fri, 14 Jun 2019 12:53:57 +0200 Subject: [PATCH 057/942] Fix typo in glfwGetRequiredInstanceExtensions docs Closes #1500. --- 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 46f9ad4b..72f93692 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5647,7 +5647,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 7bd0af3089e39de0dbed11e42463ecf84e5df769 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 058/942] Add credits --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3205c89b..027a3d04 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,7 @@ skills. - Anders Lindqvist - Eyal Lotem - Aaron Loucks + - Luflosi - Tristam MacDonald - Hans Mackowiak - Дмитри Малышев @@ -320,6 +321,7 @@ skills. - Jay Weisskopf - Frank Wille - Ryogo Yoshimura + - Lukas Zanner - Andrey Zholos - Santi Zupancic - Jonas Ådahl From 4f0b8b0ddaada126cd257f2e5b06450e932ad5f6 Mon Sep 17 00:00:00 2001 From: Leon Linhart Date: Mon, 27 May 2019 22:42:12 +0200 Subject: [PATCH 059/942] 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. --- README.md | 2 ++ src/win32_window.c | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 027a3d04..5dc67931 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,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) @@ -227,6 +228,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 24966bf4..c6876fa8 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 a4d910b4a72f3a85d7be42ea2f91162cdfd28375 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 060/942] Documentation work [ci skip] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5dc67931..d2f0e021 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,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 062a1c22b5e346b63fe8dfc09b63f1a57991461a 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 061/942] Cocoa: Fix file-local function not declared static --- 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 b5ef58c2..f1a63e3e 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 b430bc4935d8ca8ff459313dbd87ecc2b266aee1 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 062/942] Cocoa: Fix internal symbol hiding for dylib The default symbol visibility was not set to hidden on macOS. --- src/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1928670e..4ff82d7b 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 2e039d92753bcc85fee0f67d1e1eaee0d0e2e908 Mon Sep 17 00:00:00 2001 From: Ave Milia Date: Mon, 8 Jul 2019 14:54:08 +0200 Subject: [PATCH 063/942] 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. --- src/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ff82d7b..80ee9691 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 eecf83c5d00aab2ce838d179b842652fff38f5d0 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 064/942] Add credit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d2f0e021..e89e55b6 100644 --- a/README.md +++ b/README.md @@ -245,6 +245,7 @@ skills. - Jonathan Mercier - Marcel Metz - Liam Middlebrook + - Ave Milia - Jonathan Miller - Kenneth Miller - Bruce Mitchener From 6abad2efd29adfe41b5ef2e73b1650e45b1725e1 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 065/942] 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. --- tests/glfwinfo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index afc32427..0ea23fd6 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -318,7 +318,8 @@ int main(int argc, char** argv) int ch; bool list_extensions = false, list_layers = false; - 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, @@ -329,7 +330,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 }, @@ -420,7 +421,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 65748fb8f316384cda39583a489c39ae80124305 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 066/942] 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. --- README.md | 1 + tests/triangle-vulkan.c | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index e89e55b6..fb63b4fe 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,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 7cdb8f78..8600ced7 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 efda4afb495be4779c152a96f7b3f52c54cbff32 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 067/942] Put fix in correct position This fixes a mismerge by @elmindreda in 65748fb8f316384cda39583a489c39ae80124305. --- 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 8600ced7..33442968 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 711b9694a133ef338482ae75ada724e3a9915d91 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 068/942] 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. --- README.md | 2 ++ src/win32_window.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fb63b4fe..09fb5f97 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,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 c6876fa8..9e06d23c 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 2c7ef5b480d7780455deed43aedc177b9fe3ac61 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 069/942] Win32: Fix initial state of maximized state cache --- src/win32_window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32_window.c b/src/win32_window.c index 9e06d23c..0630f953 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 f764836e58ec47b7e105687630c75f8161ffcaa8 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 070/942] Fix license copyright year and formatting --- LICENSE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index acdac20b..7494a3f6 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 4cc5d2e62304432ee395b8d09f062c140810f340 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 071/942] Clarify comment --- 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 0630f953..fbb05b6a 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 56ca0cb3b30ecb1310752360e9c875fc1b2bab5e 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 072/942] Unify key name string handling This makes key names per-key static strings for all supported platforms. Fixes #1200. --- 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 72f93692..e8c9b154 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -4190,9 +4190,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 97679732..f8bfe3e6 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 1674795c..49635c95 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1503,8 +1503,10 @@ const char* _glfwPlatformGetScancodeName(int scancode) { @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 @@ const char* _glfwPlatformGetScancodeName(int scancode) 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 dbbe9d1f..33145e63 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 1398cb70..d8355ae8 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 cbf23e56151b2054003769760004dd581dda0ae1 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 073/942] Win32: Fix VS static analysis false positive This way is perhaps also more readable for humans. --- 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 988a3f95..3067b65e 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 2777f6a754a469eb9b71b4d241ca5f3b1ce5a9b1 Mon Sep 17 00:00:00 2001 From: httpdigest Date: Sat, 31 Aug 2019 02:44:04 +0200 Subject: [PATCH 074/942] 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. --- src/monitor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/monitor.c b/src/monitor.c index 4f86cb80..394026f5 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 26aac53e1d07ad9996cde7a341c7713eaa1955b5 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 075/942] Update changelog and add credit Related to #1556. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 09fb5f97..812b9c0b 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ information on what to include when reporting a bug. - Disabled tests and examples by default when built as a CMake subdirectory - 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 @@ -169,6 +170,7 @@ skills. - blanco - Kyle Brenneman - Rok Breulj + - Kai Burjack - Martin Capitanio - David Carlier - Arturo Castro From aa8e8ab960760fd3bbcb08f2a87be93c2f260aa1 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 076/942] Remove deprecated tags from Doxyfile.in This fixes warnings emitted by Doxygen 1.8.16. --- docs/Doxyfile.in | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 80ac3bd1..1c8618fd 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 7f02898264d6077738f0e8032f027eb7e252c90e 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 077/942] Cocoa: Fix glfwSetWindowSize anchor point This makes glfwSetWindowSize use the top-left corner as anchor point instead of the bottom-left corner. Fixes #1553. --- README.md | 2 ++ src/cocoa_window.m | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 812b9c0b..0fb35bd4 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] 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) @@ -228,6 +229,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 49635c95..dd8879b5 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 7105ff2dfd004a46bd732c1d0c9f461bae6d51b3 Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Mon, 12 Aug 2019 06:52:31 -0400 Subject: [PATCH 078/942] Fix typos Found via `codespell -q 3 -S ./deps -L fo,numer,te,uint,wille` --- 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 1c8618fd..825356d9 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 eb0244a7..dea64877 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 248c8516..9556ccac 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 58eb11ef..58441dbb 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 e8c9b154..dad45a49 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. @@ -4984,7 +4984,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 @@ -5205,7 +5205,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 950a52a3..260e888e 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 5c7011fd..200b004c 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -68,7 +68,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 ba7f00ab..251e15d9 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 243b1bc292a2e3f8c9aee8884574c1c7f4354402 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 25 Jul 2019 16:55:19 -0500 Subject: [PATCH 079/942] 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. --- 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 f1a63e3e..a3458152 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 3ec8f4a7f5ae83089b5f693fb97d3eb384aa33d6 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 080/942] Win32: Disable dynamic libgcc for MinGW DLL --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 80ee9691..06867308 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 3d2540c373c53a8ddfba806fb83cdb9e39a61467 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 081/942] 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. --- 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 fbb05b6a..efb4e043 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 1bd0a55aa76ceeda0537f7483bda1163405aa571 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 082/942] 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] --- .appveyor.yml | 52 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index f8aaf42d..a21829a6 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 d25248343e248337284dfbe5ecd1eddbd37ae66d Mon Sep 17 00:00:00 2001 From: Luflosi Date: Mon, 30 Sep 2019 23:17:42 +0200 Subject: [PATCH 083/942] 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. --- 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 13f4ab31..22298303 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -330,7 +330,7 @@ typedef struct _GLFWlibraryWayland typedef struct _GLFWmonitorWayland { struct wl_output* output; - int name; + uint32_t name; int currentMode; int x; From f71b55f83d5666c17d9a3ef057397b8f49704039 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 084/942] Clean up monitors tool output --- tests/monitors.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/monitors.c b/tests/monitors.c index 30ce4088..2b75d7b1 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 8f852e0833be7fa762d70c804c7856b537da9376 Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Thu, 5 Sep 2019 09:47:49 -0400 Subject: [PATCH 085/942] 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. --- src/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06867308..0af6dd05 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 545f4095921273e9c3ea562b95f331f77f2202b2 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 086/942] Add credit Related to #1576. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0fb35bd4..ff33eb88 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,7 @@ skills. - Nathan Poirier - Alexandre Pretyman - przemekmirek + - Guillaume Racicot - Philip Rideout - Eddie Ringle - Max Risuhin From 1e20218b3da47691ab5589592f41ce50856f7273 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 087/942] Use HTTPS for Discourse forum --- README.md | 2 +- docs/CONTRIBUTING.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ff33eb88..edd6560d 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,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 3bee43b9..070cff95 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 7749aac50dd404b53ac5c1b35b7935b660ecdad7 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 6 Oct 2019 22:56:58 +0200 Subject: [PATCH 088/942] 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. --- 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 a3458152..9ef2cdc9 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 3a37a089982ba66f69d3b8e15ec8c769621f7f12 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Sun, 15 Sep 2019 08:57:34 -0400 Subject: [PATCH 089/942] Fix -Wextra-semi warnings Closes #1440. --- 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 edd6560d..5fd18e4f 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,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 ce98221a..9bf5cde4 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 2adea420..5d19a451 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 d844488f..fdea9906 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 f6384a41..f593274e 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 22298303..894a4e68 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 692754a2c5e37f6384aefec327ad52c58f45216c 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 090/942] Allow AppVeyor to skip pure documentation updates --- .appveyor.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index a21829a6..2f4532eb 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 36c547875c3db6bea9e1e7d5ed8a633771dde774 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 091/942] Update changelog --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fd18e4f..3ac0f645 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,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 376897a344b53fbb7397b7466fe9499f1aeab6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Oct 2019 13:17:47 +0200 Subject: [PATCH 092/942] Replace notes for previous releases with links The news / release notes page was getting a bit long. --- docs/news.dox | 851 +------------------------------------------------- 1 file changed, 5 insertions(+), 846 deletions(-) diff --git a/docs/news.dox b/docs/news.dox index f551bb94..e3063c63 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -36,852 +36,11 @@ add_subdirectory(path/to/glfw) @subsubsection constants_34 New constants in version 3.4 -@section news_33 Release notes for version 3.3 +@section news_archive Release notes for earlier versions -These are the release notes for version 3.3. For a more detailed view including -all fixed bugs see the [version history](https://www.glfw.org/changelog.html). - -Please review the caveats, deprecations and removals if your project was written -against an earlier version of GLFW 3. - - -@subsection features_33 New features in version 3.3 - -@subsubsection gamepad_33 Gamepad input via SDL_GameControllerDB - -GLFW can now remap game controllers to a standard Xbox-like layout using -a built-in copy of SDL_GameControllerDB. Call @ref glfwJoystickIsGamepad to -check if a joystick has a mapping, @ref glfwGetGamepadState to retrieve its -input state, @ref glfwUpdateGamepadMappings to add newer mappings and @ref -glfwGetGamepadName and @ref glfwGetJoystickGUID for mapping related information. - -For more information see @ref gamepad. - - -@subsubsection moltenvk_33 Support for Vulkan on macOS via MoltenVK - -GLFW now supports [MoltenVK](https://moltengl.com/moltenvk/), a Vulkan -implementation on top of the Metal API, and its `VK_MVK_macos_surface` window -surface creation extension. MoltenVK is included in the [macOS Vulkan -SDK](https://vulkan.lunarg.com/). - -For more information see @ref vulkan_guide. - - -@subsubsection content_scale_33 Content scale queries for DPI-aware rendering - -GLFW now provides content scales for windows and monitors, i.e. the ratio -between their current DPI and the platform's default DPI, with @ref -glfwGetWindowContentScale and @ref glfwGetMonitorContentScale. - -Changes of the content scale of a window can be received with the window content -scale callback, set with @ref glfwSetWindowContentScaleCallback. - -The @ref GLFW_SCALE_TO_MONITOR window hint enables automatic resizing of a -window by the content scale of the monitor it is placed, on platforms like -Windows where this is necessary. This takes effect both on creation and when -the window is moved between monitors. It is related to but different from -[GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint). - -For more information see @ref window_scale. - - -@subsubsection setwindowattrib_33 Support for updating window attributes - -GLFW now supports changing the [GLFW_DECORATED](@ref GLFW_DECORATED_attrib), -[GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib), -[GLFW_FLOATING](@ref GLFW_FLOATING_attrib), -[GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and -[GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib) attributes for existing -windows with @ref glfwSetWindowAttrib. - -For more information see @ref window_attribs. - - -@subsubsection raw_motion_33 Support for raw mouse motion - -GLFW now supports raw (unscaled and unaccelerated) mouse motion in disabled -cursor mode with the [GLFW_RAW_MOUSE_MOTION](@ref GLFW_RAW_MOUSE_MOTION) input -mode. Raw mouse motion input is not yet implemented on macOS. Call @ref -glfwRawMouseMotionSupported to check if GLFW can provide raw mouse motion on the -current system. - -For more information see @ref raw_mouse_motion. - - -@subsubsection joysticks_33 Joystick hats - -GLFW can now return the state of hats (i.e. POVs or D-pads) of a joystick with -@ref glfwGetJoystickHats. For compatibility, hats are also exposed as buttons. -This can be disabled with the @ref GLFW_JOYSTICK_HAT_BUTTONS initialization -hint. - -For more information see @ref joystick_hat. - - -@subsubsection geterror_33 Error query - -GLFW now supports querying the last error code for the calling thread and its -human-readable description with @ref glfwGetError. This can be used instead of -or together with the error callback. - -For more information see @ref error_handling. - - -@subsubsection init_hints_33 Support for initialization hints - -GLFW now supports setting library initialization hints with @ref glfwInitHint. -These must be set before initialization to take effect. Some of these hints are -platform specific but are safe to set on any platform. - -For more information see @ref init_hints. - - -@subsubsection attention_33 User attention request - -GLFW now supports requesting user attention with @ref -glfwRequestWindowAttention. Where possible this calls attention to the -specified window. On platforms like macOS it calls attention to the whole -application. - -For more information see @ref window_attention. - - -@subsubsection maximize_33 Window maximization callback - -GLFW now supports notifying the application that the window has been maximized -@ref glfwSetWindowMaximizeCallback. This is called both when the window was -maximized by the user and when it was done with @ref glfwMaximizeWindow. - -For more information see @ref window_maximize. - - -@subsubsection workarea_33 Query for the monitor work area - -GLFW now supports querying the work area of a monitor, i.e. the area not -occupied by task bars or global menu bars, with @ref glfwGetMonitorWorkarea. On -platforms that lack this concept, the whole area of the monitor is returned. - -For more information see @ref monitor_workarea. - - -@subsubsection transparency_33 Transparent windows and framebuffers - -GLFW now supports the creation of windows with transparent framebuffers on -systems with desktop compositing enabled with the @ref -GLFW_TRANSPARENT_FRAMEBUFFER window hint and attribute. This hint must be set -before window creation and leaves any window decorations opaque. - -GLFW now also supports whole window transparency with @ref glfwGetWindowOpacity -and @ref glfwSetWindowOpacity. This value controls the opacity of the whole -window including decorations and unlike framebuffer transparency can be changed -at any time after window creation. - -For more information see @ref window_transparency. - - -@subsubsection key_scancode_33 Query for the scancode of a key - -GLFW now supports querying the platform dependent scancode of any physical key -with @ref glfwGetKeyScancode. - -For more information see @ref input_key. - - -@subsubsection center_cursor_33 Cursor centering window hint - -GLFW now supports controlling whether the cursor is centered over newly created -full screen windows with the [GLFW_CENTER_CURSOR](@ref GLFW_CENTER_CURSOR_hint) -window hint. It is enabled by default. - - -@subsubsection cursor_hover_33 Mouse cursor hover window attribute - -GLFW now supports polling whether the cursor is hovering over the window content -area with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute. This -attribute corresponds to the [cursor enter/leave](@ref cursor_enter) event. - - -@subsubsection focusonshow_33 Window hint and attribute for input focus on show - -GLFW now has the [GLFW_FOCUS_ON_SHOW](@ref GLFW_DECORATED_hint) window hint and -attribute for controlling whether a window gets input focus when shown. It is -enabled by default. It applies both when creating an visible window with @ref -glfwCreateWindow and when showing it with @ref glfwShowWindow. - -This is a workaround for GLFW 3.0 lacking @ref glfwFocusWindow and will be -corrected in the next major version. - -For more information see @ref window_hide. - - -@subsubsection device_userptr_33 Monitor and joystick user pointers - -GLFW now supports setting and querying user pointers for connected monitors and -joysticks with @ref glfwSetMonitorUserPointer, @ref glfwGetMonitorUserPointer, -@ref glfwSetJoystickUserPointer and @ref glfwGetJoystickUserPointer. - -For more information see @ref monitor_userptr and @ref joystick_userptr. - - -@subsubsection macos_nib_33 macOS menu bar from nib file - -GLFW will now load a `MainMenu.nib` file if found in the `Contents/Resources` -directory of the application bundle, as a way to replace the GLFW menu bar -without recompiling GLFW. This behavior can be disabled with the -[GLFW_COCOA_MENUBAR](@ref GLFW_COCOA_MENUBAR_hint) initialization hint. - - -@subsubsection glext_33 Support for more context creation extensions - -The context hint @ref GLFW_SRGB_CAPABLE now supports OpenGL ES via -`WGL_EXT_colorspace`, the context hint @ref GLFW_CONTEXT_NO_ERROR now supports -`WGL_ARB_create_context_no_error` and `GLX_ARB_create_context_no_error`, the -context hint @ref GLFW_CONTEXT_RELEASE_BEHAVIOR now supports -`EGL_KHR_context_flush_control` and @ref glfwGetProcAddress now supports -`EGL_KHR_get_all_proc_addresses`. - - -@subsubsection osmesa_33 OSMesa off-screen context creation support - -GLFW now supports creating off-screen OpenGL contexts using -[OSMesa](https://www.mesa3d.org/osmesa.html) by setting -[GLFW_CONTEXT_CREATION_API](@ref GLFW_CONTEXT_CREATION_API_hint) to -`GLFW_OSMESA_CONTEXT_API`. Native access function have been added to retrieve -the OSMesa color and depth buffers. - -There is also a new null backend that uses OSMesa as its native context -creation API, intended for automated testing. This backend does not provide -input. - - -@subsection caveats_33 Caveats for version 3.3 - -@subsubsection joystick_layout_33 Layout of joysticks have changed - -The way joystick elements are arranged have changed to match SDL2 in order to -support SDL_GameControllerDB mappings. The layout of joysticks may -change again if required for compatibility with SDL2. If you need a known and -stable layout for game controllers, see if you can switch to @ref gamepad. - -Existing code that depends on a specific joystick layout will likely have to be -updated. - - -@subsubsection wait_events_33 No window required to wait for events - -The @ref glfwWaitEvents and @ref glfwWaitEventsTimeout functions no longer need -a window to be created to wait for events. Before version 3.3 these functions -would return immediately if there were no user-created windows. On platforms -where only windows can receive events, an internal helper window is used. - -Existing code that depends on the earlier behavior will likely have to be -updated. - - -@subsubsection gamma_ramp_size_33 Gamma ramp size of 256 may be rejected - -The documentation for versions before 3.3 stated that a gamma ramp size of 256 -would always be accepted. This was never the case on X11 and could lead to -artifacts on macOS. The @ref glfwSetGamma function has been updated to always -generate a ramp of the correct size. - -Existing code that hardcodes a size of 256 should be updated to use the size of -the current ramp of a monitor when setting a new ramp for that monitor. - - -@subsubsection xinput_deadzone_33 Windows XInput deadzone removed - -GLFW no longer applies any deadzone to the input state received from the XInput -API. This was never done for any other platform joystick API so this change -makes the behavior more consistent but you will need to apply your own deadzone -if desired. - - -@subsubsection x11_clipboard_33 X11 clipboard transfer limits - -GLFW now supports reading clipboard text via the `INCR` method, which removes -the limit on how much text can be read with @ref glfwGetClipboardString. -However, writing via this method is not yet supported, so you may not be able to -write a very large string with @ref glfwSetClipboardString even if you read it -from the clipboard earlier. - -The exact size limit for writing to the clipboard is negotiated with each -receiving application but is at least several tens of kilobytes. Note that only -the read limit has changed. Any string that could be written before still can -be. - - -@subsubsection x11_linking_33 X11 extension libraries are loaded dynamically - -GLFW now loads all X11 extension libraries at initialization. The only X11 -library you need to link against is `libX11`. The header files for the -extension libraries are still required for compilation. - -Existing projects and makefiles that link GLFW directly against the extension -libraries should still build correctly but will add these libraries as load-time -dependencies. - - -@subsubsection cmake_version_33 CMake 3.0 or later is required - -The minimum CMake version has been raised from 2.8.12 to 3.0. This is only -a requirement of the GLFW CMake files. The GLFW source files do not depend on -CMake. - - -@subsection deprecations_33 Deprecations in version 3.3 - -@subsubsection charmods_callback_33 Character with modifiers callback - -The character with modifiers callback set with @ref glfwSetCharModsCallback has -been deprecated and should if possible not be used. - -Existing code should still work but further bug fixes will likely not be made. -The callback will be removed in the next major version. - - -@subsubsection clipboard_window_33 Window parameter to clipboard functions - -The window parameter of the clipboard functions @ref glfwGetClipboardString and -@ref glfwSetClipboardString has been deprecated and is no longer used on any -platform. On platforms where the clipboard must be owned by a specific window, -an internal helper window is used. - -Existing code should still work unless it depends on a specific window owning -the clipboard. New code may pass `NULL` as the window argument. The parameter -will be removed in a future release. - - -@subsection removals_33 Removals in 3.3 - -@subsubsection macos_options_33 macOS specific CMake options and macros - -The `GLFW_USE_RETINA`, `GLFW_USE_CHDIR` and `GLFW_USE_MENUBAR` CMake options and -the `_GLFW_USE_RETINA`, `_GLFW_USE_CHDIR` and `_GLFW_USE_MENUBAR` compile-time -macros have been removed. - -These options and macros are replaced by the window hint -[GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) -and the init hints -[GLFW_COCOA_CHDIR_RESOURCES](@ref GLFW_COCOA_CHDIR_RESOURCES_hint) and -[GLFW_COCOA_MENUBAR](@ref GLFW_COCOA_MENUBAR_hint). - -Existing projects and makefiles that set these options or define these macros -during compilation of GLFW will still build but it will have no effect and the -default behaviors will be used. - - -@subsubsection vulkan_sdk_33 LunarG Vulkan SDK dependency - -The GLFW test programs that previously depended on the LunarG Vulkan SDK now -instead uses a Vulkan loader generated by -[glad2](https://github.com/Dav1dde/glad). This means the GLFW CMake files no -longer look for the Vulkan SDK. - -Existing CMake projects that depended on the Vulkan SDK cache variables from -GLFW will need to call `find_package(Vulkan)` themselves. CMake 3.7 and later -already comes with a -[Vulkan find module](https://cmake.org/cmake/help/latest/module/FindVulkan.html) -similar to the one GLFW previously included. - - -@subsubsection lib_suffix_33 CMake option LIB_SUFFIX - -The `LIB_SUFFIX` CMake option has been removed. GLFW now uses the -GNUInstallDirs CMake package to handle platform specific details like the -library directory suffix and the `LIB_SUFFIX` CMake option has been removed. - -Existing projects and makefiles that set the `LIB_SUFFIX` option will use the -suffix chosen by the GNUInstallDirs package and the option will be ignored. - - -@subsubsection mir_removed_33 Mir support - -The experimental Mir support has been completely removed as the Mir project has -implemented support for the Wayland protocol and is recommending that -applications use that instead. - -Existing projects and makefiles that select Mir when compiling GLFW will fail. -Use Wayland or X11 instead. - - -@subsection symbols_33 New symbols in version 3.3 - -@subsubsection functions_33 New functions in version 3.3 - - - @ref glfwInitHint - - @ref glfwGetError - - @ref glfwGetMonitorWorkarea - - @ref glfwGetMonitorContentScale - - @ref glfwGetMonitorUserPointer - - @ref glfwSetMonitorUserPointer - - @ref glfwWindowHintString - - @ref glfwGetWindowContentScale - - @ref glfwGetWindowOpacity - - @ref glfwSetWindowOpacity - - @ref glfwRequestWindowAttention - - @ref glfwSetWindowAttrib - - @ref glfwSetWindowMaximizeCallback - - @ref glfwSetWindowContentScaleCallback - - @ref glfwRawMouseMotionSupported - - @ref glfwGetKeyScancode - - @ref glfwGetJoystickHats - - @ref glfwGetJoystickGUID - - @ref glfwGetJoystickUserPointer - - @ref glfwSetJoystickUserPointer - - @ref glfwJoystickIsGamepad - - @ref glfwUpdateGamepadMappings - - @ref glfwGetGamepadName - - @ref glfwGetGamepadState - - -@subsubsection types_33 New types in version 3.3 - - - @ref GLFWwindowmaximizefun - - @ref GLFWwindowcontentscalefun - - @ref GLFWgamepadstate - - -@subsubsection constants_33 New constants in version 3.3 - - - @ref GLFW_NO_ERROR - - @ref GLFW_JOYSTICK_HAT_BUTTONS - - @ref GLFW_COCOA_CHDIR_RESOURCES - - @ref GLFW_COCOA_MENUBAR - - @ref GLFW_CENTER_CURSOR - - @ref GLFW_TRANSPARENT_FRAMEBUFFER - - @ref GLFW_HOVERED - - @ref GLFW_FOCUS_ON_SHOW - - @ref GLFW_SCALE_TO_MONITOR - - @ref GLFW_COCOA_RETINA_FRAMEBUFFER - - @ref GLFW_COCOA_FRAME_NAME - - @ref GLFW_COCOA_GRAPHICS_SWITCHING - - @ref GLFW_X11_CLASS_NAME - - @ref GLFW_X11_INSTANCE_NAME - - @ref GLFW_OSMESA_CONTEXT_API - - @ref GLFW_HAT_CENTERED - - @ref GLFW_HAT_UP - - @ref GLFW_HAT_RIGHT - - @ref GLFW_HAT_DOWN - - @ref GLFW_HAT_LEFT - - @ref GLFW_HAT_RIGHT_UP - - @ref GLFW_HAT_RIGHT_DOWN - - @ref GLFW_HAT_LEFT_UP - - @ref GLFW_HAT_LEFT_DOWN - - @ref GLFW_MOD_CAPS_LOCK - - @ref GLFW_MOD_NUM_LOCK - - @ref GLFW_LOCK_KEY_MODS - - @ref GLFW_RAW_MOUSE_MOTION - - @ref GLFW_GAMEPAD_BUTTON_A - - @ref GLFW_GAMEPAD_BUTTON_B - - @ref GLFW_GAMEPAD_BUTTON_X - - @ref GLFW_GAMEPAD_BUTTON_Y - - @ref GLFW_GAMEPAD_BUTTON_LEFT_BUMPER - - @ref GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER - - @ref GLFW_GAMEPAD_BUTTON_BACK - - @ref GLFW_GAMEPAD_BUTTON_START - - @ref GLFW_GAMEPAD_BUTTON_GUIDE - - @ref GLFW_GAMEPAD_BUTTON_LEFT_THUMB - - @ref GLFW_GAMEPAD_BUTTON_RIGHT_THUMB - - @ref GLFW_GAMEPAD_BUTTON_DPAD_UP - - @ref GLFW_GAMEPAD_BUTTON_DPAD_RIGHT - - @ref GLFW_GAMEPAD_BUTTON_DPAD_DOWN - - @ref GLFW_GAMEPAD_BUTTON_DPAD_LEFT - - @ref GLFW_GAMEPAD_BUTTON_LAST - - @ref GLFW_GAMEPAD_BUTTON_CROSS - - @ref GLFW_GAMEPAD_BUTTON_CIRCLE - - @ref GLFW_GAMEPAD_BUTTON_SQUARE - - @ref GLFW_GAMEPAD_BUTTON_TRIANGLE - - @ref GLFW_GAMEPAD_AXIS_LEFT_X - - @ref GLFW_GAMEPAD_AXIS_LEFT_Y - - @ref GLFW_GAMEPAD_AXIS_RIGHT_X - - @ref GLFW_GAMEPAD_AXIS_RIGHT_Y - - @ref GLFW_GAMEPAD_AXIS_LEFT_TRIGGER - - @ref GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER - - @ref GLFW_GAMEPAD_AXIS_LAST - - -@section news_32 Release notes for 3.2 - -These are the release notes for version 3.2. For a more detailed view including -all fixed bugs see the [version history](https://www.glfw.org/changelog.html). - - -@subsection features_32 New features in version 3.2 - -@subsubsection news_32_vulkan Support for Vulkan - -GLFW now supports basic integration with Vulkan with @ref glfwVulkanSupported, -@ref glfwGetRequiredInstanceExtensions, @ref glfwGetInstanceProcAddress, @ref -glfwGetPhysicalDevicePresentationSupport and @ref glfwCreateWindowSurface. -Vulkan header inclusion can be selected with -@ref GLFW_INCLUDE_VULKAN. - - -@subsubsection news_32_setwindowmonitor Window mode switching - -GLFW now supports switching between windowed and full screen modes and updating -the monitor and desired resolution and refresh rate of full screen windows with -@ref glfwSetWindowMonitor. - - -@subsubsection news_32_maximize Window maxmimization support - -GLFW now supports window maximization with @ref glfwMaximizeWindow and the -@ref GLFW_MAXIMIZED window hint and attribute. - - -@subsubsection news_32_focus Window input focus control - -GLFW now supports giving windows input focus with @ref glfwFocusWindow. - - -@subsubsection news_32_sizelimits Window size limit support - -GLFW now supports setting both absolute and relative window size limits with -@ref glfwSetWindowSizeLimits and @ref glfwSetWindowAspectRatio. - - -@subsubsection news_32_keyname Localized key names - -GLFW now supports querying the localized name of printable keys with @ref -glfwGetKeyName, either by key token or by scancode. - - -@subsubsection news_32_waittimeout Wait for events with timeout - -GLFW now supports waiting for events for a set amount of time with @ref -glfwWaitEventsTimeout. - - -@subsubsection news_32_icon Window icon support - -GLFW now supports setting the icon of windows with @ref glfwSetWindowIcon. - - -@subsubsection news_32_timer Raw timer access - -GLFW now supports raw timer values with @ref glfwGetTimerValue and @ref -glfwGetTimerFrequency. - - -@subsubsection news_32_joystick Joystick connection callback - -GLFW now supports notifying when a joystick has been connected or disconnected -with @ref glfwSetJoystickCallback. - - -@subsubsection news_32_noapi Context-less windows - -GLFW now supports creating windows without a OpenGL or OpenGL ES context by -setting the [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_NO_API`. - - -@subsubsection news_32_contextapi Run-time context creation API selection - -GLFW now supports selecting and querying the context creation API at run-time -with the @ref GLFW_CONTEXT_CREATION_API hint and attribute. - - -@subsubsection news_32_noerror Error-free context creation - -GLFW now supports creating and querying OpenGL and OpenGL ES contexts that do -not emit errors with the @ref GLFW_CONTEXT_NO_ERROR hint, provided the machine -supports the `GL_KHR_no_error` extension. - - -@subsubsection news_32_cmake CMake config-file package support - -GLFW now supports being used as a -[config-file package](@ref build_link_cmake_package) from other projects for -easy linking with the library and its dependencies. - - -@section news_31 Release notes for 3.1 - -These are the release notes for version 3.1. For a more detailed view including -all fixed bugs see the [version history](https://www.glfw.org/changelog.html). - - -@subsection features_31 New features in version 3.1 - -@subsubsection news_31_cursor Custom mouse cursor images - -GLFW now supports creating and setting both custom cursor images and standard -cursor shapes. They are created with @ref glfwCreateCursor or @ref -glfwCreateStandardCursor, set with @ref glfwSetCursor and destroyed with @ref -glfwDestroyCursor. - -@see @ref cursor_object - - -@subsubsection news_31_drop Path drop event - -GLFW now provides a callback for receiving the paths of files and directories -dropped onto GLFW windows. The callback is set with @ref glfwSetDropCallback. - -@see @ref path_drop - - -@subsubsection news_31_emptyevent Main thread wake-up - -GLFW now provides the @ref glfwPostEmptyEvent function for posting an empty -event from another thread to the main thread event queue, causing @ref -glfwWaitEvents to return. - -@see @ref events - - -@subsubsection news_31_framesize Window frame size query - -GLFW now supports querying the size, on each side, of the frame around the -content area of a window, with @ref glfwGetWindowFrameSize. - -@see [Window size](@ref window_size) - - -@subsubsection news_31_autoiconify Simultaneous multi-monitor rendering - -GLFW now supports disabling auto-iconification of full screen windows with -the [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_hint) window hint. This is -intended for people building multi-monitor installations, where you need windows -to stay in full screen despite losing input focus. - - -@subsubsection news_31_floating Floating windows - -GLFW now supports floating windows, also called topmost or always on top, for -easier debugging with the @ref GLFW_FLOATING window hint and attribute. - - -@subsubsection news_31_focused Initially unfocused windows - -GLFW now supports preventing a windowed mode window from gaining input focus on -creation, with the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) window hint. - - -@subsubsection news_31_direct Direct access for window attributes and cursor position - -GLFW now queries the window input focus, visibility and iconification attributes -and the cursor position directly instead of returning cached data. - - -@subsubsection news_31_charmods Character with modifiers callback - -GLFW now provides a callback for character events with modifier key bits. The -callback is set with @ref glfwSetCharModsCallback. Unlike the regular character -callback, this will report character events that will not result in a character -being input, for example if the Control key is held down. - -@see @ref input_char - - -@subsubsection news_31_single Single buffered framebuffers - -GLFW now supports the creation of single buffered windows, with the @ref -GLFW_DOUBLEBUFFER hint. - - -@subsubsection news_31_glext Macro for including extension header - -GLFW now includes the extension header appropriate for the chosen OpenGL or -OpenGL ES header when @ref GLFW_INCLUDE_GLEXT is defined. GLFW does not provide -these headers. They must be provided by your development environment or your -OpenGL or OpenGL ES SDK. - - -@subsubsection news_31_release Context release behaviors - -GLFW now supports controlling and querying whether the pipeline is flushed when -a context is made non-current, with the @ref GLFW_CONTEXT_RELEASE_BEHAVIOR hint -and attribute, provided the machine supports the `GL_KHR_context_flush_control` -extension. - - -@subsubsection news_31_wayland (Experimental) Wayland support - -GLFW now has an _experimental_ Wayland display protocol backend that can be -selected on Linux with a CMake option. - - -@subsubsection news_31_mir (Experimental) Mir support - -GLFW now has an _experimental_ Mir display server backend that can be selected -on Linux with a CMake option. - - -@section news_30 Release notes for 3.0 - -These are the release notes for version 3.0. For a more detailed view including -all fixed bugs see the [version history](https://www.glfw.org/changelog.html). - - -@subsection features_30 New features in version 3.0 - -@subsubsection news_30_cmake CMake build system - -GLFW now uses the CMake build system instead of the various makefiles and -project files used by earlier versions. CMake is available for all platforms -supported by GLFW, is present in most package systems and can generate -makefiles and/or project files for most popular development environments. - -For more information on how to use CMake, see the -[CMake manual](https://cmake.org/cmake/help/documentation.html). - - -@subsubsection news_30_multiwnd Multi-window support - -GLFW now supports the creation of multiple windows, each with their own OpenGL -or OpenGL ES context, and all window functions now take a window handle. Event -callbacks are now per-window and are provided with the handle of the window that -received the event. The @ref glfwMakeContextCurrent function has been added to -select which context is current on a given thread. - - -@subsubsection news_30_multimon Multi-monitor support - -GLFW now explicitly supports multiple monitors. They can be enumerated with -@ref glfwGetMonitors, queried with @ref glfwGetVideoModes, @ref -glfwGetMonitorPos, @ref glfwGetMonitorName and @ref glfwGetMonitorPhysicalSize, -and specified at window creation to make the newly created window full screen on -that specific monitor. - - -@subsubsection news_30_unicode Unicode support - -All string arguments to GLFW functions and all strings returned by GLFW now use -the UTF-8 encoding. This includes the window title, error string, clipboard -text, monitor and joystick names as well as the extension function arguments (as -ASCII is a subset of UTF-8). - - -@subsubsection news_30_clipboard Clipboard text I/O - -GLFW now supports reading and writing plain text to and from the system -clipboard, with the @ref glfwGetClipboardString and @ref glfwSetClipboardString -functions. - - -@subsubsection news_30_gamma Gamma ramp support - -GLFW now supports setting and reading back the gamma ramp of monitors, with the -@ref glfwGetGammaRamp and @ref glfwSetGammaRamp functions. There is also @ref -glfwSetGamma, which generates a ramp from a gamma value and then sets it. - - -@subsubsection news_30_gles OpenGL ES support - -GLFW now supports the creation of OpenGL ES contexts, by setting the -[GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_OPENGL_ES_API`, where -creation of such contexts are supported. Note that GLFW _does not implement_ -OpenGL ES, so your driver must provide support in a way usable by GLFW. Modern -Nvidia and Intel drivers support creation of OpenGL ES context using the GLX and -WGL APIs, while AMD provides an EGL implementation instead. - - -@subsubsection news_30_egl (Experimental) EGL support - -GLFW now has an experimental EGL context creation back end that can be selected -through CMake options. - - -@subsubsection news_30_hidpi High-DPI support - -GLFW now supports high-DPI monitors on both Windows and macOS, giving windows -full resolution framebuffers where other UI elements are scaled up. To achieve -this, @ref glfwGetFramebufferSize and @ref glfwSetFramebufferSizeCallback have -been added. These work with pixels, while the rest of the GLFW API works with -screen coordinates. This is important as OpenGL uses pixels, not screen -coordinates. - - -@subsubsection news_30_error Error callback - -GLFW now has an error callback, which can provide your application with much -more detailed diagnostics than was previously possible. The callback is passed -an error code and a description string. - - -@subsubsection news_30_wndptr Per-window user pointer - -Each window now has a user-defined pointer, retrieved with @ref -glfwGetWindowUserPointer and set with @ref glfwSetWindowUserPointer, to make it -easier to integrate GLFW into C++ code. - - -@subsubsection news_30_iconifyfun Window iconification callback - -Each window now has a callback for iconification and restoration events, -which is set with @ref glfwSetWindowIconifyCallback. - - -@subsubsection news_30_wndposfun Window position callback - -Each window now has a callback for position events, which is set with @ref -glfwSetWindowPosCallback. - - -@subsubsection news_30_wndpos Window position query - -The position of a window can now be retrieved using @ref glfwGetWindowPos. - - -@subsubsection news_30_focusfun Window focus callback - -Each windows now has a callback for focus events, which is set with @ref -glfwSetWindowFocusCallback. - - -@subsubsection news_30_enterleave Cursor enter/leave callback - -Each window now has a callback for when the mouse cursor enters or leaves its -content area, which is set with @ref glfwSetCursorEnterCallback. - - -@subsubsection news_30_wndtitle Initial window title - -The title of a window is now specified at creation time, as one of the arguments -to @ref glfwCreateWindow. - - -@subsubsection news_30_hidden Hidden windows - -Windows can now be hidden with @ref glfwHideWindow, shown using @ref -glfwShowWindow and created initially hidden with the @ref GLFW_VISIBLE window -hint and attribute. This allows for off-screen rendering in a way compatible -with most drivers, as well as moving a window to a specific position before -showing it. - - -@subsubsection news_30_undecorated Undecorated windows - -Windowed mode windows can now be created without decorations, e.g. things like -a frame, a title bar, with the @ref GLFW_DECORATED window hint and attribute. -This allows for the creation of things like splash screens. - - -@subsubsection news_30_keymods Modifier key bit masks - -[Modifier key bit mask](@ref mods) parameters have been added to the -[mouse button](@ref GLFWmousebuttonfun) and [key](@ref GLFWkeyfun) callbacks. - - -@subsubsection news_30_scancode Platform-specific scancodes - -A scancode parameter has been added to the [key callback](@ref GLFWkeyfun). Keys -that don't have a [key token](@ref keys) still get passed on with the key -parameter set to `GLFW_KEY_UNKNOWN`. These scancodes will vary between machines -and are intended to be used for key bindings. - - -@subsubsection news_30_jsname Joystick names - -The name of a joystick can now be retrieved using @ref glfwGetJoystickName. - - -@subsubsection news_30_doxygen Doxygen documentation - -You are reading it. +- [Release notes for 3.3](https://www.glfw.org/docs/3.3/news.html) +- [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html) +- [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html) +- [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html) */ From 82978bb3affbd472060d2e64e1f7be1dd774d2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Oct 2019 13:21:59 +0200 Subject: [PATCH 093/942] Documentation work This is the documentation update for the change introduced with 0b01d850ed00abf65ede29da46ad28ca5dbf8081, removing the requirement for the forward-compatibility flag on macOS. --- docs/compat.dox | 3 +-- docs/window.dox | 10 ++++------ include/GLFW/glfw3.h | 11 +++++------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/docs/compat.dox b/docs/compat.dox index 25bfc1aa..77ba63b4 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -230,8 +230,7 @@ at most OpenGL version 2.1. Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if -given version 3.0 or 3.1. The `GLFW_OPENGL_FORWARD_COMPAT` hint must be set to -`GLFW_TRUE` and the `GLFW_OPENGL_PROFILE` hint must be set to +given version 3.0 or 3.1. The `GLFW_OPENGL_PROFILE` hint must be set to `GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The `GLFW_OPENGL_DEBUG_CONTEXT` and `GLFW_CONTEXT_NO_ERROR` hints are ignored. diff --git a/docs/window.dox b/docs/window.dox index 3a9e4a29..16276a65 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -383,12 +383,10 @@ Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested, and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x. -@note @macos The OS only supports forward-compatible core profile contexts for -OpenGL versions 3.2 and later. Before creating an OpenGL context of version -3.2 or later you must set the -[GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and -[GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly. OpenGL -3.0 and 3.1 contexts are not supported at all on macOS. +@note @macos The OS only supports core profile contexts for OpenGL versions 3.2 +and later. Before creating an OpenGL context of version 3.2 or later you must +set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hint accordingly. +OpenGL 3.0 and 3.1 contexts are not supported at all on macOS. @anchor GLFW_OPENGL_FORWARD_COMPAT_hint __GLFW_OPENGL_FORWARD_COMPAT__ specifies whether the OpenGL context should be diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index dad45a49..2aade0f0 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2580,12 +2580,11 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * @remark @win32 The context to share resources with must not be current on * any other thread. * - * @remark @macos The OS only supports forward-compatible core profile contexts - * for OpenGL versions 3.2 and later. Before creating an OpenGL context of - * version 3.2 or later you must set the - * [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and - * [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly. - * OpenGL 3.0 and 3.1 contexts are not supported at all on macOS. + * @remark @macos The OS only supports core profile contexts for OpenGL + * versions 3.2 and later. Before creating an OpenGL context of version 3.2 or + * later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) + * hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all + * on macOS. * * @remark @macos The GLFW window has no icon, as it is not a document * window, but the dock icon will be the same as the application bundle's icon. From 4d0ae4ffa74f71f91a807a08e9f09324862f1ffc Mon Sep 17 00:00:00 2001 From: Pablo Prietz Date: Thu, 24 Oct 2019 12:04:18 +0200 Subject: [PATCH 094/942] 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. --- README.md | 1 + src/CMakeLists.txt | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ac0f645..01f99df4 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,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 0af6dd05..c7364902 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 04f7f55f077bcb61081d8249ac0515b1453eedfb 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 095/942] Cleanup Related to #1585. --- README.md | 2 +- src/CMakeLists.txt | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 01f99df4..1d209ba8 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,7 @@ skills. - Konstantin Podsvirov - Nathan Poirier - Alexandre Pretyman + - Pablo Prietz - przemekmirek - Guillaume Racicot - Philip Rideout @@ -339,7 +340,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 c7364902..b78b8d37 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 33683ec60e96dd52e99c48b7e7c1dad664d234ec 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 096/942] Remove stray characters from hardcoded CFLAGS The additional '>' characters were appended to the compiler option. Related to #1576. --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b78b8d37..6cbeed6d 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 5fc4c01302b0729fd9f39e8c504e28cf7347153c 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 097/942] 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. --- README.md | 1 + src/x11_window.c | 43 +++++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1d209ba8..068a8f66 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,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) - [NSGL] Removed enforcement of forward-compatible flag for core contexts diff --git a/src/x11_window.c b/src/x11_window.c index d8355ae8..56379a3c 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) + struct { - XDeleteProperty(_glfw.x11.display, - window->x11.handle, - _glfw.x11.MOTIF_WM_HINTS); - } - else - { - 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 75294462b354d147aa5914c30e3005551cc04e4a 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 098/942] 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. --- README.md | 1 + src/x11_init.c | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 068a8f66..9b9ef7db 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,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) - [NSGL] Removed enforcement of forward-compatible flag for core contexts diff --git a/src/x11_init.c b/src/x11_init.c index ae76d36b..ca8b2ff2 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 28d850770022afc8b73d88a871fa07e8d35766b3 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 099/942] Fix order of words in window guide Fixes #1571. --- docs/window.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/window.dox b/docs/window.dox index 16276a65..705570d6 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -1398,7 +1398,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 c88ee1c9d3e018c199eaf0b0f5ccc3874ac1de09 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 100/942] 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. --- 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 705570d6..4c4ab026 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 efb4e043..455c4e2e 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 b69fb99031258f5fe37281ce4a6e44ce96e32a03 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 101/942] 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. --- src/mappings.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mappings.h b/src/mappings.h index ef76c90f..eda9a549 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 c5f1ca3e410e1f719c4e02c70c7827729cb7c888 Mon Sep 17 00:00:00 2001 From: thewoz Date: Tue, 5 Nov 2019 16:27:06 +0100 Subject: [PATCH 102/942] Add canonical build directory to .gitignore Closes #1595. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 96d5ba3f..c5c2994b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ Release MinSizeRel RelWithDebInfo *.xcodeproj +build # CMake files Makefile From 20e522cdf4b6b772e3609e95eb9773c29ed9fee1 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 103/942] Make events test output only UTF-8 in C locale --- tests/events.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/tests/events.c b/tests/events.c index 251e15d9..f29dfbb0 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 08f01c31a0b856bf5ba6b8cbce898e94ad736a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Sep 2019 19:27:09 +0200 Subject: [PATCH 104/942] Add gamepad information to events test output --- tests/events.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/events.c b/tests/events.c index f29dfbb0..1eecc4c2 100644 --- a/tests/events.c +++ b/tests/events.c @@ -503,6 +503,20 @@ static void joystick_callback(int jid, int event) axisCount, buttonCount, hatCount); + + if (glfwJoystickIsGamepad(jid)) + { + printf(" Joystick %i (%s) has a gamepad mapping (%s)\n", + jid, + glfwGetJoystickGUID(jid), + glfwGetGamepadName(jid)); + } + else + { + printf(" Joystick %i (%s) has no gamepad mapping\n", + jid, + glfwGetJoystickGUID(jid)); + } } else { From de2342945570862cde9d4ab1b3daeebc48b6d379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Sep 2019 23:31:22 +0200 Subject: [PATCH 105/942] Add reminder for why events test is not closing --- tests/events.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/events.c b/tests/events.c index 1eecc4c2..86a63df2 100644 --- a/tests/events.c +++ b/tests/events.c @@ -320,6 +320,12 @@ static void window_close_callback(GLFWwindow* window) printf("%08x to %i at %0.3f: Window close\n", counter++, slot->number, glfwGetTime()); + if (!slot->closeable) + { + printf("(( closing is disabled, press %s to re-enable )\n", + glfwGetKeyName(GLFW_KEY_C, 0)); + } + glfwSetWindowShouldClose(window, slot->closeable); } From 8e288dc94cbad84454173c137ae17d956d0b6364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Aug 2019 19:00:59 +0200 Subject: [PATCH 106/942] Win32: Add GLFW_WIN32_KEYBOARD_MENU This platform specific window hint enables access to the Windows window menu via the keyboard shortcuts. --- README.md | 2 ++ docs/news.dox | 11 +++++++++++ docs/window.dox | 9 +++++++++ include/GLFW/glfw3.h | 1 + src/internal.h | 3 +++ src/win32_platform.h | 1 + src/win32_window.c | 12 +++++++++++- src/window.c | 3 +++ tests/gamma.c | 1 + tests/inputlag.c | 1 + tests/joysticks.c | 1 + tests/opacity.c | 1 + 12 files changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b9ef7db..744cc751 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,8 @@ 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) + - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access + to the window menu - [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/docs/news.dox b/docs/news.dox index e3063c63..39f19031 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -9,6 +9,15 @@ @subsection features_34 New features in version 3.4 +@subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu + +GLFW now provides the +[GLFW_WIN32_KEYBOARD_MENU](@ref GLFW_WIN32_KEYBOARD_MENU_hint) window hint for +enabling keyboard access to the window menu via the Alt+Space and +Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented +applications. + + @subsection caveats_34 Caveats for version 3.4 @subsubsection standalone_34 Tests and examples are disabled when built as a sub-project @@ -35,6 +44,8 @@ add_subdirectory(path/to/glfw) @subsubsection types_34 New types in version 3.4 @subsubsection constants_34 New constants in version 3.4 + - @ref GLFW_WIN32_KEYBOARD_MENU + @section news_archive Release notes for earlier versions diff --git a/docs/window.dox b/docs/window.dox index 4c4ab026..868c6c21 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -455,6 +455,14 @@ The no error mode for OpenGL and OpenGL ES is described in detail by the extension. +@subsubsection window_hints_win32 Windows specific window hints + +@anchor GLFW_WIN32_KEYBOARD_MENU_hint +__GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window +menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts. This is +ignored on other platforms. + + @subsubsection window_hints_osx macOS specific window hints @anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint @@ -535,6 +543,7 @@ GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_ GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE` +GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded frame autosave name GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 2aade0f0..0b603160 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1003,6 +1003,7 @@ extern "C" { * [window hint](@ref GLFW_X11_CLASS_NAME_hint). */ #define GLFW_X11_INSTANCE_NAME 0x00024002 +#define GLFW_WIN32_KEYBOARD_MENU 0x00025001 /*! @} */ #define GLFW_NO_API 0 diff --git a/src/internal.h b/src/internal.h index acdae22d..4c75c9b1 100644 --- a/src/internal.h +++ b/src/internal.h @@ -274,6 +274,9 @@ struct _GLFWwndconfig char className[256]; char instanceName[256]; } x11; + struct { + GLFWbool keymenu; + } win32; }; // Context configuration diff --git a/src/win32_platform.h b/src/win32_platform.h index 6507c872..2b00b001 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -315,6 +315,7 @@ typedef struct _GLFWwindowWin32 // Whether to enable framebuffer transparency on DWM GLFWbool transparent; GLFWbool scaleToMonitor; + GLFWbool keymenu; // The last received cursor position, regardless of source int lastCursorPosX, lastCursorPosY; diff --git a/src/win32_window.c b/src/win32_window.c index 455c4e2e..81cdf62a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -699,7 +699,12 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // User trying to access application menu using ALT? case SC_KEYMENU: - return 0; + { + if (!window->win32.keymenu) + return 0; + + break; + } } break; } @@ -731,6 +736,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, } _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain); + + if (uMsg == WM_SYSCHAR && window->win32.keymenu) + break; + return 0; } @@ -1275,6 +1284,7 @@ static int createNativeWindow(_GLFWwindow* window, } window->win32.scaleToMonitor = wndconfig->scaleToMonitor; + window->win32.keymenu = wndconfig->win32.keymenu; // Adjust window rect to account for DPI scaling of the window frame and // (if enabled) DPI scaling of the content area diff --git a/src/window.c b/src/window.c index fa604d01..bb5ba956 100644 --- a/src/window.c +++ b/src/window.c @@ -363,6 +363,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_COCOA_RETINA_FRAMEBUFFER: _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE; return; + case GLFW_WIN32_KEYBOARD_MENU: + _glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE; + return; case GLFW_COCOA_GRAPHICS_SWITCHING: _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; return; diff --git a/tests/gamma.c b/tests/gamma.c index aa4c8b78..d1961609 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -101,6 +101,7 @@ int main(int argc, char** argv) monitor = glfwGetPrimaryMonitor(); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(800, 400, "Gamma Test", NULL, NULL); if (!window) diff --git a/tests/inputlag.c b/tests/inputlag.c index 269a0c8f..2ed4c49f 100644 --- a/tests/inputlag.c +++ b/tests/inputlag.c @@ -202,6 +202,7 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(width, height, "Input lag test", monitor, NULL); if (!window) diff --git a/tests/joysticks.c b/tests/joysticks.c index 8eae021e..d4aef36f 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -182,6 +182,7 @@ int main(void) exit(EXIT_FAILURE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(800, 600, "Joystick Test", NULL, NULL); if (!window) diff --git a/tests/opacity.c b/tests/opacity.c index 47f28b16..e1da9ef1 100644 --- a/tests/opacity.c +++ b/tests/opacity.c @@ -59,6 +59,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL); if (!window) From bc5523e994ff79304b2a690b354b7531dbbe1246 Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Sun, 3 Nov 2019 21:12:01 -0500 Subject: [PATCH 107/942] Set C standard at 99 for all test targets Related to #1593. --- tests/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fcc99243..4f49c770 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 70a3104c4977fc4ea55efb12d4c565b2581edd5c Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Sat, 9 Nov 2019 12:19:49 -0500 Subject: [PATCH 108/942] Set C standard at 99 for all example targets Closes #1593. --- examples/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 93b30ed2..7203a925 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 953a1c3f8b793dcb23879ca1032b7b62f0f27410 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 109/942] Cleanup --- 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 7203a925..597c1e13 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 4f49c770..c471d8b9 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 94cb0347abdc4e8ebf8dcf133894a764d395b84c 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 110/942] Cocoa: Add comments for Cocoa symbol macros --- 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 f8bfe3e6..21d83bcc 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 2c8eb23f..edd958e1 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 c819f27ce3e6639b4d4b432c0e5191e5c26a9d31 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 111/942] 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. --- README.md | 2 ++ src/cocoa_window.m | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 744cc751..ad41c133 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,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 dd8879b5..887bfd6f 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 bac15f94493938eded7161a7a0ab8827584e3db1 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 112/942] Cocoa: Fix multiple methods warning This fixes a warning due to us using bare ids and NSCollectionLayoutAnchor having a message with the same name. --- 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 887bfd6f..b71734ea 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 bd452016be99e10d7fa8282cd75b1c53e0d5a8cc 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 113/942] Cocoa: Cleanup Readability fix, does not affect generated code. --- 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 14253988..e455d412 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -332,7 +332,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, return GLFW_FALSE; } - NSOpenGLContext* share = NULL; + NSOpenGLContext* share = nil; if (ctxconfig->share) share = ctxconfig->share->context.nsgl.object; @@ -405,7 +405,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 2c519709be0dacc7af2908982a7ab80b889a8126 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 114/942] Cocoa: Fix full screen window iconification Iconification (miniaturization) of undecorated windows stopped working unless the window has the NSWindowStyleMaskMiniaturizable style. --- 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 b71734ea..8e0b28aa 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 e96dc5d2199032d565b55c4177820ab28b1d67c9 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 115/942] 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. --- src/x11_monitor.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 0c649580..4d3e1a94 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 359758bb53400b589e311c7d4f8732a58a40a1cd 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 116/942] Add initial .mailmap file --- .mailmap | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .mailmap diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000..96d8a9b7 --- /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 b804379463b6378e5f38803ef29ddf74adc98a9c 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 117/942] Add initial GH support file --- 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 00000000..604957d0 --- /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 50a6270e55e6d12a24031395943495120efd2d30 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 118/942] Add initial CODEOWNERS file --- 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 00000000..ec174185 --- /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 c42d8f3e5b7203a5ebb8dd7876c87b9ca282cbd4 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 119/942] Cleanup .gitignore file somewhat --- .gitignore | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c5c2994b..2d377cf7 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 -# CMake files +# macOS clutter +.DS_Store + +# Makefile generator clutter Makefile + +# CMake clutter CMakeCache.txt CMakeFiles CMakeScripts From d861d7bffe391815bce26073c38f6f8075e46410 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 120/942] Update .gitignore file This adds missing entries for Ninja and the unavoidable clutter of the modern Doxygen CMake module. --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 2d377cf7..2f580b8a 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 b5d4f24f7433bcdca17be72a78ce9b8cf6b64856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 19:57:08 +0100 Subject: [PATCH 121/942] Move CMake uninstall template file to CMake subdir --- cmake_uninstall.cmake.in => CMake/cmake_uninstall.cmake.in | 6 +++--- CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename cmake_uninstall.cmake.in => CMake/cmake_uninstall.cmake.in (78%) diff --git a/cmake_uninstall.cmake.in b/CMake/cmake_uninstall.cmake.in similarity index 78% rename from cmake_uninstall.cmake.in rename to CMake/cmake_uninstall.cmake.in index 4ea57b1c..5ecc476d 100644 --- a/cmake_uninstall.cmake.in +++ b/CMake/cmake_uninstall.cmake.in @@ -1,9 +1,9 @@ -if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +if (NOT EXISTS "@GLFW_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: \"@GLFW_BINARY_DIR@/install_manifest.txt\"") endif() -file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +file(READ "@GLFW_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") foreach (file ${files}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04174cd1..3c7ac819 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -367,7 +367,7 @@ if (GLFW_INSTALL) # Only generate this target if no higher-level project already has if (NOT TARGET uninstall) - configure_file(cmake_uninstall.cmake.in + configure_file(CMake/cmake_uninstall.cmake.in cmake_uninstall.cmake IMMEDIATE @ONLY) add_custom_target(uninstall From a9f674e719cd663560418de2a7fa1147ce6c6c9b Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Fri, 15 Nov 2019 15:30:41 +0100 Subject: [PATCH 122/942] =?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. --- 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 cdbfcf1e..40643766 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 894a4e68..542cc78d 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -247,6 +247,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 a80788c17f3376177b45d52f983d4d98f1175af2 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 21 Nov 2019 13:46:18 +0100 Subject: [PATCH 123/942] =?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. --- 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 40643766..9e692f0e 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 80fde12fdade85a39c5c1300d0a29200691fdc23 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 124/942] Wayland: Fix pointing hand cursor shape Related to #1432. --- README.md | 1 + src/wl_window.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad41c133..fc5039e8 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,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) - [NSGL] Removed enforcement of forward-compatible flag for core contexts diff --git a/src/wl_window.c b/src/wl_window.c index 200b004c..fa422ebe 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -783,7 +783,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 7dbdd2e6a5f01d2a4b377a197618948617517b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 7 May 2019 20:40:37 +0200 Subject: [PATCH 125/942] Add more standard cursors This adds the standard cursors for diagonal and omnidirectional resize/move and operation-not-allowed. It also adds new (better?) names for the horizontal and vertical resize/move and pointing hand cursors. References: - https://developer.apple.com/documentation/appkit/nscursor - https://stackoverflow.com/questions/10733228/ - https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setsystemcursor - https://freedesktop.org/wiki/Specifications/cursor-spec/ - https://tronche.com/gui/x/xlib/appendix/b/ Related to #427. --- README.md | 5 ++ docs/compat.dox | 7 +++ docs/input.dox | 5 +- docs/news.dox | 26 +++++++++ include/GLFW/glfw3.h | 136 +++++++++++++++++++++++++++++++++++++------ src/cocoa_window.m | 54 ++++++++++++----- src/init.c | 2 + src/input.c | 10 +++- src/win32_window.c | 17 +++++- src/wl_window.c | 105 +++++++++++++++++++++------------ src/x11_init.c | 6 ++ src/x11_platform.h | 9 +++ src/x11_window.c | 85 +++++++++++++++++++++------ tests/cursor.c | 45 +++++++------- 14 files changed, 393 insertions(+), 119 deletions(-) diff --git a/README.md b/README.md index fc5039e8..daa1be9c 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,11 @@ information on what to include when reporting a bug. ## Changelog + - Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`, + `GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427) + - Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427) + - Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427) + - Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427) - Disabled tests and examples by default when built as a CMake subdirectory - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) diff --git a/docs/compat.dox b/docs/compat.dox index 77ba63b4..c437e350 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -85,6 +85,13 @@ transparent window framebuffers. If the running X server does not support this extension or there is no running compositing manager, the `GLFW_TRANSPARENT_FRAMEBUFFER` framebuffer hint will have no effect. +GLFW uses both the Xcursor extension and the freedesktop cursor conventions to +provide an expanded set of standard cursor shapes. If the running X server does +not support this extension or the current cursor theme does not support the +conventions, the `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR` and +`GLFW_NOT_ALLOWED_CURSOR` shapes will not be available and other shapes may use +legacy images. + @section compat_wayland Wayland protocols and IPC standards diff --git a/docs/input.dox b/docs/input.dox index dea64877..331f9718 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -373,12 +373,15 @@ A cursor with a [standard shape](@ref shapes) from the current system cursor theme can be can be created with @ref glfwCreateStandardCursor. @code -GLFWcursor* cursor = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); +GLFWcursor* url_cursor = glfwCreateStandardCursor(GLFW_POINTING_HAND_CURSOR); @endcode These cursor objects behave in the exact same way as those created with @ref glfwCreateCursor except that the system cursor theme provides the actual image. +A few of these shapes are not available everywhere. If a shape is unavailable, +`NULL` is returned. See @ref glfwCreateStandardCursor for details. + @subsubsection cursor_destruction Cursor destruction diff --git a/docs/news.dox b/docs/news.dox index 39f19031..f18537af 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -9,6 +9,24 @@ @subsection features_34 New features in version 3.4 +@subsubsection standard_cursors_34 More standard cursors + +GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and +@ref GLFW_RESIZE_NESW_CURSOR for diagonal resizing, @ref GLFW_RESIZE_ALL_CURSOR +for omni-directional resizing and @ref GLFW_NOT_ALLOWED_CURSOR for showing an +action is not allowed. + +Unlike the original set, these shapes may not be available everywhere and +creation will then fail with the new @ref GLFW_CURSOR_UNAVAILABLE error. + +The cursors for horizontal and vertical resizing are now referred to as @ref +GLFW_RESIZE_EW_CURSOR and @ref GLFW_RESIZE_NS_CURSOR, and the pointing hand +cursor is now referred to as @ref GLFW_POINTING_HAND_CURSOR. The older names +are still available. + +For more information see @ref cursor_standard. + + @subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu GLFW now provides the @@ -44,6 +62,14 @@ add_subdirectory(path/to/glfw) @subsubsection types_34 New types in version 3.4 @subsubsection constants_34 New constants in version 3.4 + - @ref GLFW_POINTING_HAND_CURSOR + - @ref GLFW_RESIZE_EW_CURSOR + - @ref GLFW_RESIZE_NS_CURSOR + - @ref GLFW_RESIZE_NWSE_CURSOR + - @ref GLFW_RESIZE_NESW_CURSOR + - @ref GLFW_RESIZE_ALL_CURSOR + - @ref GLFW_NOT_ALLOWED_CURSOR + - @ref GLFW_CURSOR_UNAVAILABLE - @ref GLFW_WIN32_KEYBOARD_MENU diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 0b603160..8b5b87dd 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -757,6 +757,17 @@ extern "C" { * @analysis Application programmer error. Fix the offending call. */ #define GLFW_NO_WINDOW_CONTEXT 0x0001000A +/*! @brief The specified cursor shape is not available. + * + * The specified standard cursor shape is not available, either because the + * current system cursor theme does not provide it or because it is not + * available on the platform. + * + * @analysis Platform or system settings limitation. Pick another + * [standard cursor shape](@ref shapes) or create a + * [custom cursor](@ref cursor_custom). + */ +#define GLFW_CURSOR_UNAVAILABLE 0x0001000B /*! @} */ /*! @addtogroup window @@ -1039,14 +1050,15 @@ extern "C" { /*! @defgroup shapes Standard cursor shapes * @brief Standard system cursor shapes. * - * See [standard cursor creation](@ref cursor_standard) for how these are used. + * These are the [standard cursor shapes](@ref cursor_standard) that can be + * requested from the window system. * * @ingroup input * @{ */ /*! @brief The regular arrow cursor shape. * - * The regular arrow cursor. + * The regular arrow cursor shape. */ #define GLFW_ARROW_CURSOR 0x00036001 /*! @brief The text input I-beam cursor shape. @@ -1054,26 +1066,91 @@ extern "C" { * The text input I-beam cursor shape. */ #define GLFW_IBEAM_CURSOR 0x00036002 -/*! @brief The crosshair shape. +/*! @brief The crosshair cursor shape. * - * The crosshair shape. + * The crosshair cursor shape. */ #define GLFW_CROSSHAIR_CURSOR 0x00036003 -/*! @brief The hand shape. +/*! @brief The pointing hand cursor shape. * - * The hand shape. + * The pointing hand cursor shape. */ -#define GLFW_HAND_CURSOR 0x00036004 -/*! @brief The horizontal resize arrow shape. +#define GLFW_POINTING_HAND_CURSOR 0x00036004 +/*! @brief The horizontal resize/move arrow shape. * - * The horizontal resize arrow shape. + * The horizontal resize/move arrow shape. This is usually a horizontal + * double-headed arrow. */ -#define GLFW_HRESIZE_CURSOR 0x00036005 -/*! @brief The vertical resize arrow shape. +#define GLFW_RESIZE_EW_CURSOR 0x00036005 +/*! @brief The vertical resize/move arrow shape. * - * The vertical resize arrow shape. + * The vertical resize/move shape. This is usually a vertical double-headed + * arrow. */ -#define GLFW_VRESIZE_CURSOR 0x00036006 +#define GLFW_RESIZE_NS_CURSOR 0x00036006 +/*! @brief The top-left to bottom-right diagonal resize/move arrow shape. + * + * The top-left to bottom-right diagonal resize/move shape. This is usually + * a diagonal double-headed arrow. + * + * @note @macos This shape is provided by a private system API and may fail + * with @ref GLFW_CURSOR_UNAVAILABLE in the future. + * + * @note @x11 This shape is provided by a newer standard not supported by all + * cursor themes. + * + * @note @wayland This shape is provided by a newer standard not supported by + * all cursor themes. + */ +#define GLFW_RESIZE_NWSE_CURSOR 0x00036007 +/*! @brief The top-right to bottom-left diagonal resize/move arrow shape. + * + * The top-right to bottom-left diagonal resize/move shape. This is usually + * a diagonal double-headed arrow. + * + * @note @macos This shape is provided by a private system API and may fail + * with @ref GLFW_CURSOR_UNAVAILABLE in the future. + * + * @note @x11 This shape is provided by a newer standard not supported by all + * cursor themes. + * + * @note @wayland This shape is provided by a newer standard not supported by + * all cursor themes. + */ +#define GLFW_RESIZE_NESW_CURSOR 0x00036008 +/*! @brief The omni-directional resize/move cursor shape. + * + * The omni-directional resize cursor/move shape. This is usually either + * a combined horizontal and vertical double-headed arrow or a grabbing hand. + */ +#define GLFW_RESIZE_ALL_CURSOR 0x00036009 +/*! @brief The operation-not-allowed shape. + * + * The operation-not-allowed shape. This is usually a circle with a diagonal + * line through it. + * + * @note @x11 This shape is provided by a newer standard not supported by all + * cursor themes. + * + * @note @wayland This shape is provided by a newer standard not supported by + * all cursor themes. + */ +#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A +/*! @brief Legacy name for compatibility. + * + * This is an alias for compatibility with earlier versions. + */ +#define GLFW_HRESIZE_CURSOR GLFW_RESIZE_EW_CURSOR +/*! @brief Legacy name for compatibility. + * + * This is an alias for compatibility with earlier versions. + */ +#define GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR +/*! @brief Legacy name for compatibility. + * + * This is an alias for compatibility with earlier versions. + */ +#define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR /*! @} */ #define GLFW_CONNECTED 0x00040001 @@ -4417,19 +4494,44 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot) /*! @brief Creates a cursor with a standard shape. * - * Returns a cursor with a [standard shape](@ref shapes), that can be set for - * a window with @ref glfwSetCursor. + * Returns a cursor with a standard shape, that can be set for a window with + * @ref glfwSetCursor. The images for these cursors come from the system + * cursor theme and their exact appearance will vary between platforms. + * + * Most of these shapes are guaranteed to exist on every supported platform but + * a few may not be present. See the table below for details. + * + * Cursor shape | Windows | macOS | X11 | Wayland + * ------------------------------ | ------- | ----- | ------ | ------- + * @ref GLFW_ARROW_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_IBEAM_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_CROSSHAIR_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_POINTING_HAND_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_RESIZE_EW_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_RESIZE_NS_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes1 | Maybe2 | Maybe2 + * @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes1 | Maybe2 | Maybe2 + * @ref GLFW_RESIZE_ALL_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe2 | Maybe2 + * + * 1) This uses a private system API and may fail in the future. + * + * 2) This uses a newer standard that not all cursor themes support. + * + * If the requested shape is not available, this function emits a @ref + * GLFW_CURSOR_UNAVAILABLE error and returns `NULL`. * * @param[in] shape One of the [standard shapes](@ref shapes). * @return A new cursor ready to use or `NULL` if an * [error](@ref error_handling) occurred. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref + * GLFW_PLATFORM_ERROR. * * @thread_safety This function must only be called from the main thread. * - * @sa @ref cursor_object + * @sa @ref cursor_standard * @sa @ref glfwCreateCursor * * @since Added in version 3.1. diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 8e0b28aa..bfec8b7b 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1603,23 +1603,49 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { @autoreleasepool { - if (shape == GLFW_ARROW_CURSOR) - cursor->ns.object = [NSCursor arrowCursor]; - else if (shape == GLFW_IBEAM_CURSOR) - cursor->ns.object = [NSCursor IBeamCursor]; - else if (shape == GLFW_CROSSHAIR_CURSOR) - cursor->ns.object = [NSCursor crosshairCursor]; - else if (shape == GLFW_HAND_CURSOR) - cursor->ns.object = [NSCursor pointingHandCursor]; - else if (shape == GLFW_HRESIZE_CURSOR) - cursor->ns.object = [NSCursor resizeLeftRightCursor]; - else if (shape == GLFW_VRESIZE_CURSOR) - cursor->ns.object = [NSCursor resizeUpDownCursor]; + SEL cursorSelector = NULL; + + // HACK: Try to use a private message + if (shape == GLFW_RESIZE_EW_CURSOR) + cursorSelector = @selector(_windowResizeEastWestCursor); + else if (shape == GLFW_RESIZE_NS_CURSOR) + cursorSelector = @selector(_windowResizeNorthSouthCursor); + else if (shape == GLFW_RESIZE_NWSE_CURSOR) + cursorSelector = @selector(_windowResizeNorthWestSouthEastCursor); + else if (shape == GLFW_RESIZE_NESW_CURSOR) + cursorSelector = @selector(_windowResizeNorthEastSouthWestCursor); + + if (cursorSelector && [NSCursor respondsToSelector:cursorSelector]) + { + id object = [NSCursor performSelector:cursorSelector]; + if ([object isKindOfClass:[NSCursor class]]) + cursor->ns.object = object; + } if (!cursor->ns.object) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to retrieve standard cursor"); + if (shape == GLFW_ARROW_CURSOR) + cursor->ns.object = [NSCursor arrowCursor]; + else if (shape == GLFW_IBEAM_CURSOR) + cursor->ns.object = [NSCursor IBeamCursor]; + else if (shape == GLFW_CROSSHAIR_CURSOR) + cursor->ns.object = [NSCursor crosshairCursor]; + else if (shape == GLFW_POINTING_HAND_CURSOR) + cursor->ns.object = [NSCursor pointingHandCursor]; + else if (shape == GLFW_RESIZE_EW_CURSOR) + cursor->ns.object = [NSCursor resizeLeftRightCursor]; + else if (shape == GLFW_RESIZE_NS_CURSOR) + cursor->ns.object = [NSCursor resizeUpDownCursor]; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + cursor->ns.object = [NSCursor closedHandCursor]; + else if (shape == GLFW_NOT_ALLOWED_CURSOR) + cursor->ns.object = [NSCursor operationNotAllowedCursor]; + } + + if (!cursor->ns.object) + { + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "Cocoa: Standard cursor shape unavailable"); return GLFW_FALSE; } diff --git a/src/init.c b/src/init.c index 96feab0c..13baff70 100644 --- a/src/init.c +++ b/src/init.c @@ -189,6 +189,8 @@ void _glfwInputError(int code, const char* format, ...) strcpy(description, "The requested format is unavailable"); else if (code == GLFW_NO_WINDOW_CONTEXT) strcpy(description, "The specified window has no context"); + else if (code == GLFW_CURSOR_UNAVAILABLE) + strcpy(description, "The specified cursor shape is unavailable"); else strcpy(description, "ERROR: UNKNOWN GLFW ERROR"); } diff --git a/src/input.c b/src/input.c index 28291750..f6163093 100644 --- a/src/input.c +++ b/src/input.c @@ -757,9 +757,13 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape) if (shape != GLFW_ARROW_CURSOR && shape != GLFW_IBEAM_CURSOR && shape != GLFW_CROSSHAIR_CURSOR && - shape != GLFW_HAND_CURSOR && - shape != GLFW_HRESIZE_CURSOR && - shape != GLFW_VRESIZE_CURSOR) + shape != GLFW_POINTING_HAND_CURSOR && + shape != GLFW_RESIZE_EW_CURSOR && + shape != GLFW_RESIZE_NS_CURSOR && + shape != GLFW_RESIZE_NWSE_CURSOR && + shape != GLFW_RESIZE_NESW_CURSOR && + shape != GLFW_RESIZE_ALL_CURSOR && + shape != GLFW_NOT_ALLOWED_CURSOR) { _glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor 0x%08X", shape); return NULL; diff --git a/src/win32_window.c b/src/win32_window.c index 81cdf62a..3a50c542 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2068,14 +2068,25 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) id = OCR_IBEAM; else if (shape == GLFW_CROSSHAIR_CURSOR) id = OCR_CROSS; - else if (shape == GLFW_HAND_CURSOR) + else if (shape == GLFW_POINTING_HAND_CURSOR) id = OCR_HAND; - else if (shape == GLFW_HRESIZE_CURSOR) + else if (shape == GLFW_RESIZE_EW_CURSOR) id = OCR_SIZEWE; - else if (shape == GLFW_VRESIZE_CURSOR) + else if (shape == GLFW_RESIZE_NS_CURSOR) id = OCR_SIZENS; + else if (shape == GLFW_RESIZE_NWSE_CURSOR) + id = OCR_SIZENWSE; + else if (shape == GLFW_RESIZE_NESW_CURSOR) + id = OCR_SIZENESW; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + id = OCR_SIZEALL; + else if (shape == GLFW_NOT_ALLOWED_CURSOR) + id = OCR_NO; else + { + _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor"); return GLFW_FALSE; + } cursor->win32.handle = LoadImageW(NULL, MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0, diff --git a/src/wl_window.c b/src/wl_window.c index fa422ebe..c8dde30a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -770,28 +770,6 @@ static void handleEvents(int timeout) } } -// Translates a GLFW standard cursor to a theme cursor name -// -static char *translateCursorShape(int shape) -{ - switch (shape) - { - case GLFW_ARROW_CURSOR: - return "left_ptr"; - case GLFW_IBEAM_CURSOR: - return "xterm"; - case GLFW_CROSSHAIR_CURSOR: - return "crosshair"; - case GLFW_HAND_CURSOR: - return "hand2"; - case GLFW_HRESIZE_CURSOR: - return "sb_h_double_arrow"; - case GLFW_VRESIZE_CURSOR: - return "sb_v_double_arrow"; - } - return NULL; -} - ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// @@ -1233,26 +1211,79 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { - struct wl_cursor* standardCursor; + const char* name = NULL; - standardCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, - translateCursorShape(shape)); - if (!standardCursor) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Standard cursor \"%s\" not found", - translateCursorShape(shape)); - return GLFW_FALSE; - } + // Try the XDG names first + if (shape == GLFW_ARROW_CURSOR) + name = "default"; + else if (shape == GLFW_IBEAM_CURSOR) + name = "text"; + else if (shape == GLFW_CROSSHAIR_CURSOR) + name = "crosshair"; + else if (shape == GLFW_POINTING_HAND_CURSOR) + name = "pointer"; + else if (shape == GLFW_RESIZE_EW_CURSOR) + name = "ew-resize"; + else if (shape == GLFW_RESIZE_NS_CURSOR) + name = "ns-resize"; + else if (shape == GLFW_RESIZE_NWSE_CURSOR) + name = "nwse-resize"; + else if (shape == GLFW_RESIZE_NESW_CURSOR) + name = "nesw-resize"; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + name = "all-scroll"; + else if (shape == GLFW_NOT_ALLOWED_CURSOR) + name = "not-allowed"; - cursor->wl.cursor = standardCursor; - cursor->wl.currentImage = 0; + cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); if (_glfw.wl.cursorThemeHiDPI) { - standardCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, - translateCursorShape(shape)); - cursor->wl.cursorHiDPI = standardCursor; + cursor->wl.cursorHiDPI = + wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name); + } + + if (!cursor->wl.cursor) + { + // Fall back to the core X11 names + if (shape == GLFW_ARROW_CURSOR) + name = "left_ptr"; + else if (shape == GLFW_IBEAM_CURSOR) + name = "xterm"; + else if (shape == GLFW_CROSSHAIR_CURSOR) + name = "crosshair"; + else if (shape == GLFW_POINTING_HAND_CURSOR) + name = "hand2"; + else if (shape == GLFW_RESIZE_EW_CURSOR) + name = "sb_h_double_arrow"; + else if (shape == GLFW_RESIZE_NS_CURSOR) + name = "sb_v_double_arrow"; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + name = "fleur"; + else + { + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "Wayland: Standard cursor shape unavailable"); + return GLFW_FALSE; + } + + cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); + if (!cursor->wl.cursor) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create standard cursor \"%s\"", + name); + return GLFW_FALSE; + } + + if (_glfw.wl.cursorThemeHiDPI) + { + if (!cursor->wl.cursorHiDPI) + { + cursor->wl.cursorHiDPI = + wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name); + } + } } return GLFW_TRUE; diff --git a/src/x11_init.c b/src/x11_init.c index ca8b2ff2..d44d4e2a 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -615,6 +615,12 @@ static GLFWbool initExtensions(void) _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy"); _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor) _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor"); + _glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme) + _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetTheme"); + _glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize) + _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize"); + _glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage) + _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage"); } #if defined(__CYGWIN__) diff --git a/src/x11_platform.h b/src/x11_platform.h index 33145e63..cb3b1068 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -85,9 +85,15 @@ typedef int (* PFN_XRRUpdateConfiguration)(XEvent*); typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int); typedef void (* PFN_XcursorImageDestroy)(XcursorImage*); typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*); +typedef char* (* PFN_XcursorGetTheme)(Display*); +typedef int (* PFN_XcursorGetDefaultSize)(Display*); +typedef XcursorImage* (* PFN_XcursorLibraryLoadImage)(const char*,const char*,int); #define XcursorImageCreate _glfw.x11.xcursor.ImageCreate #define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy #define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor +#define XcursorGetTheme _glfw.x11.xcursor.GetTheme +#define XcursorGetDefaultSize _glfw.x11.xcursor.GetDefaultSize +#define XcursorLibraryLoadImage _glfw.x11.xcursor.LibraryLoadImage typedef Bool (* PFN_XineramaIsActive)(Display*); typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*); @@ -352,6 +358,9 @@ typedef struct _GLFWlibraryX11 PFN_XcursorImageCreate ImageCreate; PFN_XcursorImageDestroy ImageDestroy; PFN_XcursorImageLoadCursor ImageLoadCursor; + PFN_XcursorGetTheme GetTheme; + PFN_XcursorGetDefaultSize GetDefaultSize; + PFN_XcursorLibraryLoadImage LibraryLoadImage; } xcursor; struct { diff --git a/src/x11_window.c b/src/x11_window.c index 56379a3c..9f0312ce 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2823,29 +2823,76 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { - int native = 0; + if (_glfw.x11.xcursor.handle) + { + char* theme = XcursorGetTheme(_glfw.x11.display); + if (theme) + { + const int size = XcursorGetDefaultSize(_glfw.x11.display); + const char* name = NULL; - if (shape == GLFW_ARROW_CURSOR) - native = XC_left_ptr; - else if (shape == GLFW_IBEAM_CURSOR) - native = XC_xterm; - else if (shape == GLFW_CROSSHAIR_CURSOR) - native = XC_crosshair; - else if (shape == GLFW_HAND_CURSOR) - native = XC_hand2; - else if (shape == GLFW_HRESIZE_CURSOR) - native = XC_sb_h_double_arrow; - else if (shape == GLFW_VRESIZE_CURSOR) - native = XC_sb_v_double_arrow; - else - return GLFW_FALSE; + if (shape == GLFW_ARROW_CURSOR) + name = "default"; + else if (shape == GLFW_IBEAM_CURSOR) + name = "text"; + else if (shape == GLFW_CROSSHAIR_CURSOR) + name = "crosshair"; + else if (shape == GLFW_POINTING_HAND_CURSOR) + name = "pointer"; + else if (shape == GLFW_RESIZE_EW_CURSOR) + name = "ew-resize"; + else if (shape == GLFW_RESIZE_NS_CURSOR) + name = "ns-resize"; + else if (shape == GLFW_RESIZE_NWSE_CURSOR) + name = "nwse-resize"; + else if (shape == GLFW_RESIZE_NESW_CURSOR) + name = "nesw-resize"; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + name = "all-scroll"; + else if (shape == GLFW_NOT_ALLOWED_CURSOR) + name = "not-allowed"; + + XcursorImage* image = XcursorLibraryLoadImage(name, theme, size); + if (image) + { + cursor->x11.handle = XcursorImageLoadCursor(_glfw.x11.display, image); + XcursorImageDestroy(image); + } + } + } - cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native); if (!cursor->x11.handle) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "X11: Failed to create standard cursor"); - return GLFW_FALSE; + unsigned int native = 0; + + if (shape == GLFW_ARROW_CURSOR) + native = XC_left_ptr; + else if (shape == GLFW_IBEAM_CURSOR) + native = XC_xterm; + else if (shape == GLFW_CROSSHAIR_CURSOR) + native = XC_crosshair; + else if (shape == GLFW_POINTING_HAND_CURSOR) + native = XC_hand2; + else if (shape == GLFW_RESIZE_EW_CURSOR) + native = XC_sb_h_double_arrow; + else if (shape == GLFW_RESIZE_NS_CURSOR) + native = XC_sb_v_double_arrow; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + native = XC_fleur; + else + { + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "X11: Standard cursor shape unavailable"); + return GLFW_FALSE; + } + + cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native); + if (!cursor->x11.handle) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "X11: Failed to create standard cursor"); + return GLFW_FALSE; + } } return GLFW_TRUE; diff --git a/tests/cursor.c b/tests/cursor.c index b6288f6a..f72c0f91 100644 --- a/tests/cursor.c +++ b/tests/cursor.c @@ -69,7 +69,7 @@ static int swap_interval = 1; static int wait_events = GLFW_TRUE; static int animate_cursor = GLFW_FALSE; static int track_cursor = GLFW_FALSE; -static GLFWcursor* standard_cursors[6]; +static GLFWcursor* standard_cursors[10]; static GLFWcursor* tracking_cursor = NULL; static void error_callback(int error, const char* description) @@ -271,28 +271,24 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, break; case GLFW_KEY_1: - glfwSetCursor(window, standard_cursors[0]); - break; - case GLFW_KEY_2: - glfwSetCursor(window, standard_cursors[1]); - break; - case GLFW_KEY_3: - glfwSetCursor(window, standard_cursors[2]); - break; - case GLFW_KEY_4: - glfwSetCursor(window, standard_cursors[3]); - break; - case GLFW_KEY_5: - glfwSetCursor(window, standard_cursors[4]); - break; - case GLFW_KEY_6: - glfwSetCursor(window, standard_cursors[5]); + case GLFW_KEY_7: + case GLFW_KEY_8: + case GLFW_KEY_9: + { + int index = key - GLFW_KEY_1; + if (mods & GLFW_MOD_SHIFT) + index += 9; + + if (index < sizeof(standard_cursors) / sizeof(standard_cursors[0])) + glfwSetCursor(window, standard_cursors[index]); + break; + } case GLFW_KEY_F11: case GLFW_KEY_ENTER: @@ -358,17 +354,16 @@ int main(void) GLFW_ARROW_CURSOR, GLFW_IBEAM_CURSOR, GLFW_CROSSHAIR_CURSOR, - GLFW_HAND_CURSOR, - GLFW_HRESIZE_CURSOR, - GLFW_VRESIZE_CURSOR + GLFW_POINTING_HAND_CURSOR, + GLFW_RESIZE_EW_CURSOR, + GLFW_RESIZE_NS_CURSOR, + GLFW_RESIZE_NWSE_CURSOR, + GLFW_RESIZE_NESW_CURSOR, + GLFW_RESIZE_ALL_CURSOR, + GLFW_NOT_ALLOWED_CURSOR }; standard_cursors[i] = glfwCreateStandardCursor(shapes[i]); - if (!standard_cursors[i]) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); From ef6189f348d7f911afe640e6b817e2e945dc86a1 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 28 Nov 2019 15:47:09 +0100 Subject: [PATCH 126/942] 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. --- src/wl_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wl_init.c b/src/wl_init.c index 9e692f0e..3507c8cf 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 382943f2b006badfdfdc549187aa470bf4b54bf7 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 127/942] Add Xcode section to .gitignore file --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2f580b8a..2a7da22a 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 b3544ca43e2fd328aa084f118789c7eeda5869a8 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 128/942] Cocoa: Update outdated comment --- 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 01c1b319..70e45216 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -431,9 +431,8 @@ static GLFWbool initializeTIS(void) // 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 6e6805000ac7ddf39c8c5f6be3e877770cba5083 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 129/942] 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. --- 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 daa1be9c..57206a06 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,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 70e45216..7e75299a 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -447,9 +447,9 @@ static GLFWbool initializeTIS(void) - (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 bfec8b7b..3d55d6d7 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 fa602692455d87e11c9ff5a5fb0681ca6403772a 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 130/942] NSGL: Fix disabling of Retina resolution It appears the default is now YES. Fixes #1442. --- README.md | 2 ++ src/nsgl_context.m | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 57206a06..15370970 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,8 @@ information on what to include when reporting a bug. - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [NSGL] Removed enforcement of forward-compatible flag for core contexts + - [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 e455d412..febbded2 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -354,8 +354,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 7dd14a4b2086944e8c936cea14906db4b410f933 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 131/942] Fix .gitignore entries for VS with CMake --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2a7da22a..428e7334 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,8 @@ _ReSharper* *.dir *.vcxproj* *.sln -.vs/ +.vs +CMakeSettings.json Win32 x64 Debug From 92c70b2a83f8902a018cc53915eecd3f423bc931 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 132/942] Rename CMake variable for GUI-only programs Hopefully this is less ambiguous. --- 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 597c1e13..f265fcd3 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 splitview triangle-opengl wave) +set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview + triangle-opengl 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 c471d8b9..675592c4 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 d74c18117d73968dc58ac514e416df83ce398617 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 133/942] Remove dependency on platform header paths The tests and examples should not need these paths. --- 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 f265fcd3..7fb0728c 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 675592c4..e10d58e3 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 f6d44cedfdf5d61ce5acd461da5a9eadd01e6898 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 134/942] 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. --- src/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6cbeed6d..fc5ba016 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 ce9d124243dd2302c608ed0664a5e857158870ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 26 Nov 2019 17:47:27 +0100 Subject: [PATCH 135/942] Remove command-line options from GUI-only test --- tests/CMakeLists.txt | 2 +- tests/windows.c | 93 +++++++++++++++++++------------------------- 2 files changed, 41 insertions(+), 54 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e10d58e3..ae350ff4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -51,7 +51,7 @@ 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(windows WIN32 MACOSX_BUNDLE windows.c ${GETOPT} ${GLAD_GL}) +add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GLAD_GL}) target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}") target_link_libraries(threads "${CMAKE_THREAD_LIBS_INIT}") diff --git a/tests/windows.c b/tests/windows.c index 6669856f..881338fb 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -34,8 +34,7 @@ #include #include -#include "getopt.h" - +static GLFWwindow* windows[4]; static const char* titles[] = { "Red", @@ -55,20 +54,26 @@ static const struct { 0.98f, 0.74f, 0.04f } }; -static void usage(void) -{ - printf("Usage: windows [-h] [-b] [-f] \n"); - printf("Options:\n"); - printf(" -b create decorated windows\n"); - printf(" -f set focus on show off for all but first window\n"); - printf(" -h show this help\n"); -} - static void error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); } +static void arrange_windows(void) +{ + int xbase, ybase; + glfwGetWindowPos(windows[0], &xbase, &ybase); + + for (int i = 0; i < 4; i++) + { + int left, top, right, bottom; + glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom); + glfwSetWindowPos(windows[i], + xbase + (i & 1) * (200 + left + right), + ybase + (i >> 1) * (200 + top + bottom)); + } +} + static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (action != GLFW_PRESS) @@ -87,49 +92,34 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, case GLFW_KEY_ESCAPE: glfwSetWindowShouldClose(window, GLFW_TRUE); break; + + case GLFW_KEY_D: + { + for (int i = 0; i < 4; i++) + { + const int decorated = glfwGetWindowAttrib(windows[i], GLFW_DECORATED); + glfwSetWindowAttrib(windows[i], GLFW_DECORATED, !decorated); + } + + arrange_windows(); + break; + } } } int main(int argc, char** argv) { - int i, ch; - int decorated = GLFW_FALSE; - int focusOnShow = GLFW_TRUE; - int running = GLFW_TRUE; - GLFWwindow* windows[4]; - - while ((ch = getopt(argc, argv, "bfh")) != -1) - { - switch (ch) - { - case 'b': - decorated = GLFW_TRUE; - break; - case 'f': - focusOnShow = GLFW_FALSE; - break; - case 'h': - usage(); - exit(EXIT_SUCCESS); - default: - usage(); - exit(EXIT_FAILURE); - } - } - glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); - glfwWindowHint(GLFW_DECORATED, decorated); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { - int left, top, right, bottom; - if (i) - glfwWindowHint(GLFW_FOCUS_ON_SHOW, focusOnShow); + if (i > 0) + glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE); windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL); if (!windows[i]) @@ -143,32 +133,29 @@ int main(int argc, char** argv) glfwMakeContextCurrent(windows[i]); gladLoadGL(glfwGetProcAddress); glClearColor(colors[i].r, colors[i].g, colors[i].b, 1.f); - - glfwGetWindowFrameSize(windows[i], &left, &top, &right, &bottom); - glfwSetWindowPos(windows[i], - 100 + (i & 1) * (200 + left + right), - 100 + (i >> 1) * (200 + top + bottom)); } - for (i = 0; i < 4; i++) + arrange_windows(); + + for (int i = 0; i < 4; i++) glfwShowWindow(windows[i]); - while (running) + for (;;) { - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { glfwMakeContextCurrent(windows[i]); glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(windows[i]); if (glfwWindowShouldClose(windows[i])) - running = GLFW_FALSE; + { + glfwTerminate(); + exit(EXIT_SUCCESS); + } } glfwWaitEvents(); } - - glfwTerminate(); - exit(EXIT_SUCCESS); } From bc7b19cbd1e4d52660743965a31b2349c74962af 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 136/942] Remove tab character --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc5ba016..8530909e 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 dff6253ca7a83c597d793fa11a8ff799b8ccb099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 26 Nov 2019 19:09:34 +0100 Subject: [PATCH 137/942] Add installation of HTML documentation --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c7ac819..a74014dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -365,6 +365,11 @@ if (GLFW_INSTALL) install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + if (GLFW_BUILD_DOCS) + install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html" + DESTINATION "${CMAKE_INSTALL_DOCDIR}") + endif() + # Only generate this target if no higher-level project already has if (NOT TARGET uninstall) configure_file(CMake/cmake_uninstall.cmake.in From 9486ec0c0223dc4e5f51a44fdc9c7d28b5a1d059 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 138/942] Fix source list for -Wdeclaration-after-statement The context creation files were not included on platforms other than Win32. --- src/CMakeLists.txt | 13 ++++++------- src/egl_context.c | 31 ++++++++++++++++--------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8530909e..306e47ff 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 6a33396f..706a7922 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}; - - // 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) + XVisualInfo vi = {0}; + + // Only consider EGLConfigs with associated Visuals + vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID); + if (!vi.visualid) + continue; + + 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 2fb336268fd6e0e755389f67ca93064074a26508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 3 Dec 2019 22:03:36 +0100 Subject: [PATCH 139/942] Shorten name of Info.plist template file Our template file is not simply a copy of the file included in CMake and so should not be named as if it was. --- CMake/{MacOSXBundleInfo.plist.in => Info.plist.in} | 0 examples/CMakeLists.txt | 2 +- include/GLFW/glfw3.h | 2 +- tests/CMakeLists.txt | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename CMake/{MacOSXBundleInfo.plist.in => Info.plist.in} (100%) diff --git a/CMake/MacOSXBundleInfo.plist.in b/CMake/Info.plist.in similarity index 100% rename from CMake/MacOSXBundleInfo.plist.in rename to CMake/Info.plist.in diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7fb0728c..53563a48 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -84,6 +84,6 @@ if (APPLE) MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_ICON_FILE glfw.icns - MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in") + MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/Info.plist.in") endif() diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 8b5b87dd..d6843f68 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2685,7 +2685,7 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html) * in the Mac Developer Library. The GLFW test and example programs use * a custom `Info.plist` template for this, which can be found as - * `CMake/MacOSXBundleInfo.plist.in` in the source tree. + * `CMake/Info.plist.in` in the source tree. * * @remark @macos When activating frame autosaving with * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ae350ff4..1c3815b7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -90,6 +90,6 @@ if (APPLE) 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") + MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/Info.plist.in") endif() From 135d87aa3c8a6f821025e60b1a0ff506bb3db3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 3 Dec 2019 22:17:48 +0100 Subject: [PATCH 140/942] Remove inclusion of X11 extension header paths They should be found in X11/extensions on every platform. --- CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a74014dc..578abc0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,12 +229,6 @@ if (_GLFW_X11) if (NOT X11_Xi_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_Xi_INCLUDE_PATH}") endif() #-------------------------------------------------------------------- From 197193ac0b37979a1b8fa95f568a4e5fb7bc8bac 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 141/942] Fix source list for Objective-C fix --- src/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 306e47ff..4c59196c 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 c81def70be066e650ca46e67ce7b42bbc970e146 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 142/942] Remove unneccessary example target property Bundle icon file copying is performed by MACOSX_PACKAGE_LOCATION. --- examples/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 53563a48..0b976815 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 9dc365f192a8c32ba8aa50a59aa169e2cea03002 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 143/942] Merge GCC/Clang specific CMake blocks --- src/CMakeLists.txt | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c59196c..ae2f0eab 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 c194193797d454f46ccdf08f2ce7b7bff33f637f 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 144/942] Replace CMake generator expression with variable Generator expressions are amazing but best used in moderation. --- src/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ae2f0eab..cf82f0f6 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 db76abb63c257a45a04cbfa9810c3b1692990510 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 145/942] Make target-specific define target-specific --- examples/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0b976815..ce3e8c08 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 c016b26852075e1eba87b29a9e22c127a97a5825 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 146/942] Remove non-GUI binaries from GUI-only setup --- tests/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1c3815b7..8fe49eb3 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/Info.plist.in") From 5f4a6f689adc739a8aa5fc961dfdf3de54b40edb 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 147/942] Gather all macOS specific CMake properties --- examples/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ce3e8c08..7e633169 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 8a1f4940fcccacdd8fb51578d75a9fdf37ad71df 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 148/942] Remove reference to non-existent CMake variable --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8fe49eb3..5571a3c9 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 ${GLAD_GL}) target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}") From 59055d585f2dd7fed4ff15bf2881bf7e13e0fa94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 26 Nov 2019 18:09:22 +0100 Subject: [PATCH 149/942] Update minimum required CMake version to 3.1 --- CMakeLists.txt | 2 +- README.md | 4 +++- examples/CMakeLists.txt | 12 +----------- src/CMakeLists.txt | 13 +------------ tests/CMakeLists.txt | 12 +----------- 5 files changed, 7 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 578abc0a..f87ec976 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.1) project(GLFW VERSION 3.4.0 LANGUAGES C) diff --git a/README.md b/README.md index 15370970..b2c3a7ca 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,8 @@ in the documentation for more information. ## Dependencies -GLFW itself depends only on the headers and libraries for your window system. +GLFW itself needs only CMake 3.1 or later and the headers and libraries for your +OS and window system. The (experimental) Wayland backend also depends on the `extra-cmake-modules` package, which is used to generated Wayland protocol headers. @@ -123,6 +124,7 @@ information on what to include when reporting a bug. - Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427) - Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427) - Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427) + - Updated the minimum required CMake version to 3.1 - Disabled tests and examples by default when built as a CMake subdirectory - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7e633169..050dff02 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,17 +17,6 @@ elseif (APPLE) set(ICON glfw.icns) 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" @@ -55,6 +44,7 @@ set(GUI_ONLY_BINARIES boing gears heightmap particles sharing splitview set(CONSOLE_BINARIES offscreen) set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES + C_STANDARD 99 FOLDER "GLFW3/Examples") if (GLFW_USE_OSMESA) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf82f0f6..5b3d2e1e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -85,20 +85,9 @@ set_target_properties(glfw PROPERTIES VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR} SOVERSION ${GLFW_VERSION_MAJOR} POSITION_INDEPENDENT_CODE ON + C_STANDARD 99 FOLDER "GLFW3") -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 - 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 "$" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5571a3c9..275f20c1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,17 +20,6 @@ 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}) @@ -66,6 +55,7 @@ set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen cursor) set_target_properties(${GUI_ONLY_BINARIES} ${CONSOLE_BINARIES} PROPERTIES + C_STANDARD 99 FOLDER "GLFW3/Tests") if (MSVC) From a43f54567773c38ee9dda4ab6b6a65fd58a67080 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 150/942] Add dependency name hints to CMake error messages Fixes #1605. --- CMakeLists.txt | 12 ++++++------ README.md | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f87ec976..63d17c1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,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") @@ -207,27 +207,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() endif() diff --git a/README.md b/README.md index b2c3a7ca..6472e4ea 100644 --- a/README.md +++ b/README.md @@ -303,6 +303,7 @@ skills. - Alexandre Pretyman - Pablo Prietz - przemekmirek + - pthom - Guillaume Racicot - Philip Rideout - Eddie Ringle From ac30ef3e0c6cac8bbd54b142eadfedd8dd3fe91b Mon Sep 17 00:00:00 2001 From: Luflosi Date: Wed, 28 Aug 2019 21:28:23 +0200 Subject: [PATCH 151/942] Fix typo Fixes #1601. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6472e4ea..bc84763c 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 7e03bce1387696918bef4a7022cb5cc3db39e2ea 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 152/942] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc84763c..24350b3b 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ GLFW itself needs only CMake 3.1 or later and the headers and libraries for your OS and 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 2551829f75d293d7b4e910b4957798caff01b847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 11 Dec 2019 19:09:59 +0100 Subject: [PATCH 153/942] Win32: Add VERSIONINFO resource to GLFW DLL This will let people see the API version in the Explorer property box. --- README.md | 1 + src/CMakeLists.txt | 5 +++++ src/glfw.rc.in | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/glfw.rc.in diff --git a/README.md b/README.md index 24350b3b..9c86531e 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ information on what to include when reporting a bug. - Bugfix: Compiling with -Wextra-semi caused warnings (#1440) - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu + - [Win32] Added a version info resource to the GLFW DLL - [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/CMakeLists.txt b/src/CMakeLists.txt index 5b3d2e1e..35b24e6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,6 +72,11 @@ if (_GLFW_X11 OR _GLFW_WAYLAND) endif() endif() +if (WIN32 AND BUILD_SHARED_LIBS) + configure_file(glfw.rc.in glfw.rc @ONLY) + set(glfw_SOURCES ${glfw_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc") +endif() + if (APPLE) # 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 diff --git a/src/glfw.rc.in b/src/glfw.rc.in new file mode 100644 index 00000000..ac3460a7 --- /dev/null +++ b/src/glfw.rc.in @@ -0,0 +1,30 @@ + +#include + +VS_VERSION_INFO VERSIONINFO +FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 +PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0 +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE 0 +{ + BLOCK "StringFileInfo" + { + BLOCK "040904B0" + { + VALUE "CompanyName", "GLFW" + VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL" + VALUE "FileVersion", "@GLFW_VERSION@" + VALUE "OriginalFilename", "glfw3.dll" + VALUE "ProductName", "GLFW" + VALUE "ProductVersion", "@GLFW_VERSION@" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x409, 1200 + } +} + From a875a536b76233d7f3024cf9aec17086aa6bc795 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 154/942] Cocoa: Fix duplicate conversion of title string --- 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 3d55d6d7..63157e99 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 506a6aafdee2bb043da5cef6e28377466dda2f09 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 155/942] Formatting --- 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 63157e99..cf31dfb5 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 081484ed340da6ccab5d0e3442c9d10a1b385ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 17:24:26 +0100 Subject: [PATCH 156/942] Fix POSIX conformance issues for clock_gettime CLOCK_MONOTONIC should not be used as a feature macro. The POSIX feature macros are provided by unistd.h. CLOCK_MONOTONIC is provided by time.h. CLOCK_MONOTONIC requires _POSIX_C_SOURCE >= 199309L on some systems. --- README.md | 2 ++ src/posix_time.c | 7 +++++-- src/wl_init.c | 3 +++ src/x11_init.c | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9c86531e..87796081 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,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) + - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled + - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [NSGL] Removed enforcement of forward-compatible flag for core contexts - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer macOS versions (#1442) diff --git a/src/posix_time.c b/src/posix_time.c index 301cb958..ae3d5c78 100644 --- a/src/posix_time.c +++ b/src/posix_time.c @@ -27,8 +27,11 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#define _POSIX_C_SOURCE 199309L + #include "internal.h" +#include #include #include @@ -41,7 +44,7 @@ // void _glfwInitTimerPOSIX(void) { -#if defined(CLOCK_MONOTONIC) +#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) @@ -64,7 +67,7 @@ void _glfwInitTimerPOSIX(void) uint64_t _glfwPlatformGetTimerValue(void) { -#if defined(CLOCK_MONOTONIC) +#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) if (_glfw.timer.posix.monotonic) { struct timespec ts; diff --git a/src/wl_init.c b/src/wl_init.c index 3507c8cf..558ff8a8 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -26,6 +26,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#define _POSIX_C_SOURCE 199309L + #include "internal.h" #include @@ -38,6 +40,7 @@ #include #include #include +#include #include diff --git a/src/x11_init.c b/src/x11_init.c index d44d4e2a..2b7bc7f1 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -36,6 +36,7 @@ #include #include #include +#include // Translate an X11 key code to a GLFW key code. From a264d3298753ea3c3cefe154757d6d54a48a6178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 07:37:26 +0100 Subject: [PATCH 157/942] Replace CMake list variables with target_sources --- src/CMakeLists.txt | 136 ++++++++++++++++++++++----------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 35b24e6b..be385b2d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,90 +1,83 @@ -set(common_HEADERS internal.h mappings.h - "${GLFW_BINARY_DIR}/src/glfw_config.h" - "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" - "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h") -set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c) +add_library(glfw "${GLFW_BINARY_DIR}/src/glfw_config.h" + "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" + "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h" + internal.h mappings.h context.c init.c input.c monitor.c + vulkan.c window.c) if (_GLFW_COCOA) - set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h - posix_thread.h nsgl_context.h egl_context.h osmesa_context.h) - set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_joystick.m - cocoa_monitor.m cocoa_window.m cocoa_time.c posix_thread.c - nsgl_context.m egl_context.c osmesa_context.c) + target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h posix_thread.h + nsgl_context.h egl_context.h osmesa_context.h + cocoa_init.m cocoa_joystick.m cocoa_monitor.m + cocoa_window.m cocoa_time.c posix_thread.c + nsgl_context.m egl_context.c osmesa_context.c) elseif (_GLFW_WIN32) - set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_joystick.h - wgl_context.h egl_context.h osmesa_context.h) - set(glfw_SOURCES ${common_SOURCES} 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) + target_sources(glfw PRIVATE win32_platform.h win32_joystick.h wgl_context.h + egl_context.h osmesa_context.h 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) elseif (_GLFW_X11) - set(glfw_HEADERS ${common_HEADERS} x11_platform.h xkb_unicode.h posix_time.h - posix_thread.h glx_context.h egl_context.h osmesa_context.h) - set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c - xkb_unicode.c posix_time.c posix_thread.c glx_context.c - egl_context.c osmesa_context.c) + target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h posix_time.h + posix_thread.h glx_context.h egl_context.h + osmesa_context.h x11_init.c x11_monitor.c + x11_window.c xkb_unicode.c posix_time.c + posix_thread.c glx_context.c egl_context.c + osmesa_context.c) elseif (_GLFW_WAYLAND) - set(glfw_HEADERS ${common_HEADERS} wl_platform.h - posix_time.h posix_thread.h xkb_unicode.h egl_context.h - osmesa_context.h) - set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c - posix_time.c posix_thread.c xkb_unicode.c - egl_context.c osmesa_context.c) - - ecm_add_wayland_client_protocol(glfw_SOURCES - PROTOCOL - "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml" - BASENAME xdg-shell) - ecm_add_wayland_client_protocol(glfw_SOURCES - PROTOCOL - "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml" - BASENAME xdg-decoration) - ecm_add_wayland_client_protocol(glfw_SOURCES - PROTOCOL - "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml" - BASENAME viewporter) - ecm_add_wayland_client_protocol(glfw_SOURCES - PROTOCOL - "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml" - BASENAME relative-pointer-unstable-v1) - ecm_add_wayland_client_protocol(glfw_SOURCES - PROTOCOL - "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml" - BASENAME pointer-constraints-unstable-v1) - ecm_add_wayland_client_protocol(glfw_SOURCES - PROTOCOL - "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" - BASENAME idle-inhibit-unstable-v1) + target_sources(glfw PRIVATE wl_platform.h posix_time.h posix_thread.h + xkb_unicode.h egl_context.h osmesa_context.h + wl_init.c wl_monitor.c wl_window.c posix_time.c + posix_thread.c xkb_unicode.c egl_context.c + osmesa_context.c) elseif (_GLFW_OSMESA) - set(glfw_HEADERS ${common_HEADERS} null_platform.h null_joystick.h - posix_time.h posix_thread.h osmesa_context.h) - set(glfw_SOURCES ${common_SOURCES} null_init.c null_monitor.c null_window.c - null_joystick.c posix_time.c posix_thread.c osmesa_context.c) + target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h + posix_thread.h osmesa_context.h null_init.c + null_monitor.c null_window.c null_joystick.c + posix_time.c posix_thread.c osmesa_context.c) endif() if (_GLFW_X11 OR _GLFW_WAYLAND) if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - set(glfw_HEADERS ${glfw_HEADERS} linux_joystick.h) - set(glfw_SOURCES ${glfw_SOURCES} linux_joystick.c) + target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c) else() - set(glfw_HEADERS ${glfw_HEADERS} null_joystick.h) - set(glfw_SOURCES ${glfw_SOURCES} null_joystick.c) + target_sources(glfw PRIVATE null_joystick.h null_joystick.c) endif() endif() +if (_GLFW_WAYLAND) + ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES + PROTOCOL + "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml" + BASENAME xdg-shell) + ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES + PROTOCOL + "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml" + BASENAME xdg-decoration) + ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES + PROTOCOL + "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml" + BASENAME viewporter) + ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES + PROTOCOL + "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml" + BASENAME relative-pointer-unstable-v1) + ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES + PROTOCOL + "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml" + BASENAME pointer-constraints-unstable-v1) + ecm_add_wayland_client_protocol(GLFW_WAYLAND_PROTOCOL_SOURCES + PROTOCOL + "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" + BASENAME idle-inhibit-unstable-v1) + target_sources(glfw PRIVATE ${GLFW_WAYLAND_PROTOCOL_SOURCES}) +endif() + if (WIN32 AND BUILD_SHARED_LIBS) configure_file(glfw.rc.in glfw.rc @ONLY) - set(glfw_SOURCES ${glfw_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc") + target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc") endif() -if (APPLE) - # 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() - -add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) set_target_properties(glfw PROPERTIES OUTPUT_NAME ${GLFW_LIB_NAME} VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR} @@ -103,6 +96,13 @@ target_include_directories(glfw PRIVATE ${glfw_INCLUDE_DIRS}) target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) +if (APPLE) + # 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() + if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") From a5ed740d9d97580e162e07cbd36648969c61688b 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 158/942] Fix use of CMake 3.13 command target_link_options --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be385b2d..824fbaef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -133,7 +133,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 8a5fd0c5a45e5b387b08732e44d2f7fd0d27fc15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 09:21:58 +0100 Subject: [PATCH 159/942] Replace ad-hoc CMake code with DEFINE_SYMBOL This target property does what we were doing manually. --- CMakeLists.txt | 4 ---- src/CMakeLists.txt | 1 + src/glfw_config.h.in | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63d17c1d..1e110288 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,10 +37,6 @@ cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" 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) -endif() - if (BUILD_SHARED_LIBS AND UNIX) # On Unix-like systems, shared libraries can use the soname system. set(GLFW_LIB_NAME glfw) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 824fbaef..70978159 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -84,6 +84,7 @@ set_target_properties(glfw PROPERTIES SOVERSION ${GLFW_VERSION_MAJOR} POSITION_INDEPENDENT_CODE ON C_STANDARD 99 + DEFINE_SYMBOL _GLFW_BUILD_DLL FOLDER "GLFW3") target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index 018952d2..f4876da2 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -45,8 +45,6 @@ // Define this to 1 if building GLFW for OSMesa #cmakedefine _GLFW_OSMESA -// Define this to 1 if building as a shared library / dynamic library / DLL -#cmakedefine _GLFW_BUILD_DLL // Define this to 1 to use Vulkan loader linked statically into application #cmakedefine _GLFW_VULKAN_STATIC From 49c5d837b4667e2c6e09a54f4141fc744af0558f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 09:53:18 +0100 Subject: [PATCH 160/942] Replace CMake threads variable with modern target --- CMakeLists.txt | 5 ++--- examples/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- tests/CMakeLists.txt | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e110288..eded1072 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ if (_GLFW_X11) # Set up library and include paths list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}") - list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}") + list(APPEND glfw_LIBRARIES "${X11_X11_LIB}") # Check for XRandR (modern resolution switching and gamma control) if (NOT X11_Xrandr_INCLUDE_PATH) @@ -241,7 +241,7 @@ if (_GLFW_WAYLAND) list(APPEND glfw_PKG_DEPS "wayland-egl") list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}") - list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}") + list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}") find_package(XKBCommon REQUIRED) list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}") @@ -265,7 +265,6 @@ endif() #-------------------------------------------------------------------- if (_GLFW_OSMESA) find_package(OSMesa REQUIRED) - list(APPEND glfw_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") endif() #-------------------------------------------------------------------- diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 050dff02..867f5bcf 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -34,7 +34,7 @@ add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD_GL}) add_executable(triangle-opengl WIN32 MACOSX_BUNDLE triangle-opengl.c ${ICON} ${GLAD_GL}) add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL}) -target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}") +target_link_libraries(particles Threads::Threads) if (RT_LIBRARY) target_link_libraries(particles "${RT_LIBRARY}") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70978159..5e2ad87b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -95,7 +95,7 @@ target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/src" "${GLFW_BINARY_DIR}/src" ${glfw_INCLUDE_DIRS}) -target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) +target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES}) if (APPLE) # For some reason CMake didn't know about .m until version 3.16 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 275f20c1..e36ed56c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -42,8 +42,8 @@ add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL}) add_executable(triangle-vulkan WIN32 triangle-vulkan.c ${GLAD_VULKAN}) add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GLAD_GL}) -target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}") -target_link_libraries(threads "${CMAKE_THREAD_LIBS_INIT}") +target_link_libraries(empty Threads::Threads) +target_link_libraries(threads Threads::Threads) if (RT_LIBRARY) target_link_libraries(empty "${RT_LIBRARY}") target_link_libraries(threads "${RT_LIBRARY}") From 18307467b48547a0a9d4e053c1c6e3efa024c1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 09:11:40 +0100 Subject: [PATCH 161/942] Gather CMake setup of configuration header --- CMakeLists.txt | 2 -- src/CMakeLists.txt | 8 +++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eded1072..11f1dde1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -315,8 +315,6 @@ write_basic_package_version_file(src/glfw3ConfigVersion.cmake VERSION ${GLFW_VERSION} COMPATIBILITY SameMajorVersion) -configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY) - configure_file(src/glfw3.pc.in src/glfw3.pc @ONLY) #-------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5e2ad87b..91a66b96 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,5 @@ -add_library(glfw "${GLFW_BINARY_DIR}/src/glfw_config.h" - "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" +add_library(glfw "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h" internal.h mappings.h context.c init.c input.c monitor.c vulkan.c window.c) @@ -78,6 +77,10 @@ if (WIN32 AND BUILD_SHARED_LIBS) target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc") endif() +configure_file(glfw_config.h.in glfw_config.h @ONLY) +target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) +target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw_config.h") + set_target_properties(glfw PROPERTIES OUTPUT_NAME ${GLFW_LIB_NAME} VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR} @@ -87,7 +90,6 @@ set_target_properties(glfw PROPERTIES DEFINE_SYMBOL _GLFW_BUILD_DLL FOLDER "GLFW3") -target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) target_include_directories(glfw PUBLIC "$" "$") From 994c3b4e486f04614da5a9ce0c8f1deb3d738df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 16:32:06 +0100 Subject: [PATCH 162/942] Cocoa: Remove stale GCC workaround --- src/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 91a66b96..687351c4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -150,9 +150,6 @@ if (BUILD_SHARED_LIBS) 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") - set_target_properties(glfw PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}") endif() From fb0028c766c6404acabc2c8e582b0129fc966c3b 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 163/942] Win32: Enable Unicode mode for all compilers --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 687351c4..4d79c092 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -123,6 +123,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 da3f20d860deb39b0e5db497bbaaaef8ad01bec6 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 164/942] Win32: Add missing include for wcscmp --- src/win32_monitor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 3067b65e..5f91c579 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 bc3be40f2167dc59d720202d6f81224eda63ff45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 15 Dec 2019 17:37:42 +0100 Subject: [PATCH 165/942] Enable strict C99 for non-VS compilers --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4d79c092..3fb2a54e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,6 +87,7 @@ set_target_properties(glfw PROPERTIES SOVERSION ${GLFW_VERSION_MAJOR} POSITION_INDEPENDENT_CODE ON C_STANDARD 99 + C_EXTENSIONS OFF DEFINE_SYMBOL _GLFW_BUILD_DLL FOLDER "GLFW3") From 4837b78ffe48aa9fab7a9657347b77cba104979a 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 166/942] 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. --- README.md | 1 + src/x11_window.c | 67 +++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 87796081..6490a60c 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,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) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled diff --git a/src/x11_window.c b/src/x11_window.c index 9f0312ce..91c57981 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 9b6d68ec70da775c4e2bf6481f86117cf9d9f551 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 167/942] X11: Fix missing checks for EWMH attention atoms --- src/x11_window.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/x11_window.c b/src/x11_window.c index 91c57981..604b186b 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 0b652a44d2afe593d6eca8a0d586c20555a0497c 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 168/942] X11: Fix invalid read when clearing GLFW_FLOATING --- README.md | 1 + src/x11_window.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6490a60c..3406ac6e 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,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) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled diff --git a/src/x11_window.c b/src/x11_window.c index 604b186b..d40a1d07 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 9db156421f038e5a269a63d59e509f4fb1e2392b 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 169/942] X11: Fix updating GLFW_FLOATING on a hidden window --- README.md | 1 + src/x11_window.c | 39 ++++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3406ac6e..b4551bb4 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,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) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled diff --git a/src/x11_window.c b/src/x11_window.c index d40a1d07..ac21c98d 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 4e70c95aa3bcb666320e17f2097f33d18a7fc225 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 170/942] X11: Cleanup The window state action is not an atom. --- 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 ac21c98d..4c2d75ba 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 73a8ebb691813ccdc1531c1bd916c352ac0b7574 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 171/942] X11: Cleanup This is technically valid but misleading and may inspire future bugs like the one fixed by 0b652a44d2afe593d6eca8a0d586c20555a0497c. --- 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 4c2d75ba..35fd2456 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 28773a069ede8aa7f93af59d3135cd6c6efd26fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 20 Dec 2019 08:10:56 +0100 Subject: [PATCH 172/942] Cocoa: Fix undeclared selector warnings --- src/cocoa_window.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index cf31dfb5..fa629024 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1617,13 +1617,13 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) // HACK: Try to use a private message if (shape == GLFW_RESIZE_EW_CURSOR) - cursorSelector = @selector(_windowResizeEastWestCursor); + cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor"); else if (shape == GLFW_RESIZE_NS_CURSOR) - cursorSelector = @selector(_windowResizeNorthSouthCursor); + cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor"); else if (shape == GLFW_RESIZE_NWSE_CURSOR) - cursorSelector = @selector(_windowResizeNorthWestSouthEastCursor); + cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor"); else if (shape == GLFW_RESIZE_NESW_CURSOR) - cursorSelector = @selector(_windowResizeNorthEastSouthWestCursor); + cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor"); if (cursorSelector && [NSCursor respondsToSelector:cursorSelector]) { From b4a8eb9b197caebcec1304cd3d55cd56e3869376 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 173/942] 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. --- 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 9ef2cdc9..631cc0f6 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 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) *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 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) 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 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) } 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 21d83bcc..c9f96ee0 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 54e8e0b0928400a9da7ebb9d27ad686ee756686e 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 174/942] NSGL: Remove problematic swap interval workaround Fixes #1483. --- 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 b4551bb4..3fae47ed 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,7 @@ information on what to include when reporting a bug. - [NSGL] Removed enforcement of forward-compatible flag for core contexts - [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 fa629024..546f9a82 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -322,12 +322,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _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 edd958e1..9c31436c 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 febbded2..6c20fca0 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; @@ -356,14 +309,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; @@ -371,26 +318,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 c3ca88055f7c2c8b02b38cb90fc1989990552977 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 175/942] NSGL: Simulate vsync for occluded windows This only supports a swap interval of zero or one, as that is all NSGL supports. --- 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 6c20fca0..e011fa5e 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 4ec7daf3e92440efab8dac7c1f4c60707d990ed0 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 176/942] 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. --- CMakeLists.txt | 5 ++- README.md | 1 + docs/build.dox | 6 ++-- docs/news.dox | 6 ++++ src/cocoa_monitor.m | 73 +++++++++++++++++++++++++++++++++++--------- src/cocoa_platform.h | 2 -- 6 files changed, 70 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11f1dde1..8d8719da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,11 +275,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 3fae47ed..fb210747 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,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 127c9f06..7c3b8ae2 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -344,8 +344,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 @@ -359,7 +359,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/docs/news.dox b/docs/news.dox index f18537af..81af3d1d 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -52,6 +52,12 @@ add_subdirectory(path/to/glfw) @endcode +@subsubsection corevideo_34 CoreVideo dependency has been removed + +GLFW no longer depends on the CoreVideo framework on macOS and it no longer +needs to be specified during compilation or linking. + + @subsection deprecations_34 Deprecations in version 3.4 @subsection removals_34 Removals in 3.4 diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 631cc0f6..42f2dce2 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) { - 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; } + while ((service = IOIteratorNext(it)) != 0) + { + const CFNumberRef indexRef = + IORegistryEntryCreateCFProperty(service, + CFSTR("IOFramebufferOpenGLIndex"), + kCFAllocatorDefault, + kNilOptions); + if (!indexRef) + continue; + + uint32_t index = 0; + CFNumberGetValue(indexRef, kCFNumberIntType, &index); + CFRelease(indexRef); + + 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; + + 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 c9f96ee0..434f46dd 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 74a46dfa0cca79e871b24dbbb9e595b4fe65e0f6 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 6 Oct 2019 22:53:42 +0200 Subject: [PATCH 177/942] 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. --- 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 b98f9f67..88636a87 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 8149a5fc00e63ff1e94228f338f1a27de374c68b 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 178/942] X11: Cleanup We can use C99 now and also we will need the event mask below. --- src/x11_window.c | 68 ++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 35fd2456..0d9fdbad 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 = { 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) { - 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); + _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 a3d28ef52cec2fb69941bbce8a7ed7a2a22a8c41 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 179/942] X11: Fix IC event mask not being added to our window --- src/x11_window.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/x11_window.c b/src/x11_window.c index 0d9fdbad..0b6b614b 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 5dd207048cc957bcf680e6c7f80eff8faf92ccb7 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 180/942] Set macOS deployment target in Travis CI build --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9b37ebfd..5f3b7393 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 781fbbadb0bccc749058177b1385c82da9ace880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Dec 2019 15:34:01 +0100 Subject: [PATCH 181/942] Fix Threads package not located by our config file This fixes a missing dependency error when the imported GLFW target is a static library. Thanks to @mosra for reporting the bug. --- src/glfw3Config.cmake.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/glfw3Config.cmake.in b/src/glfw3Config.cmake.in index 1fa200e2..4a13a88b 100644 --- a/src/glfw3Config.cmake.in +++ b/src/glfw3Config.cmake.in @@ -1 +1,3 @@ +include(CMakeFindDependencyMacro) +find_dependency(Threads) include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake") From bf292f0083df14e0c8e0bf10c599681d460c9179 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 182/942] Update changelog and add credit --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index fb210747..325a4094 100644 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ 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] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - [Win32] Added a version info resource to the GLFW DLL @@ -139,11 +140,13 @@ 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) + - [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) @@ -152,6 +155,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) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled @@ -231,6 +236,7 @@ skills. - GeO4d - Marcus Geelnard - Charles Giessen + - Ryan C. Gordon - Stephen Gowen - Kovid Goyal - Eloi Marín Gratacós From 6b01affd89975c7d08c98036ce0882d8ac540f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 1 Jan 2020 01:43:40 +0100 Subject: [PATCH 183/942] Update changelog --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 325a4094..fc4f02a8 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,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 + - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled From fe57e3c2921a1901390534e1e51053df70b5644b 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 184/942] 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. --- README.md | 1 + src/x11_platform.h | 1 + src/x11_window.c | 44 +++++++++++++++++++++++++++++++++----------- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index fc4f02a8..d3cf5da1 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,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] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/x11_platform.h b/src/x11_platform.h index cb3b1068..04c46647 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -186,6 +186,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 0b6b614b..8a00b34f 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) - { - if (window->x11.overrideRedirect || event->xany.send_event) - { - _glfwInputWindowPos(window, - event->xconfigure.x, - event->xconfigure.y); + int xpos = event->xconfigure.x; + int ypos = event->xconfigure.y; - window->x11.xpos = event->xconfigure.x; - window->x11.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) + { + Window dummy; + XTranslateCoordinates(_glfw.x11.display, + window->x11.parent, + _glfw.x11.root, + xpos, ypos, + &xpos, &ypos, + &dummy); + } + + if (xpos != window->x11.xpos || ypos != window->x11.ypos) + { + _glfwInputWindowPos(window, xpos, ypos); + window->x11.xpos = xpos; + window->x11.ypos = ypos; } return; From aa5e31356178de43d42f43f48914a62c25033f4b 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 185/942] 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. --- README.md | 1 + src/x11_window.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3cf5da1..51d0c668 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,7 @@ information on what to include when reporting a bug. - [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) + - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/x11_window.c b/src/x11_window.c index 8a00b34f..5f174f87 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 9372ba95faabd1bb45280d201d6ccdae77bf872e 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 186/942] 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. --- 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 5f174f87..98388bd8 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 c5cb4a253a9c304b136cac01a378567dc46e0320 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 187/942] Cocoa: Add support for VK_EXT_metal_surface This adds optional support for the VK_EXT_metal_surface instance extension. Closes #1619. --- CMakeLists.txt | 2 ++ docs/compat.dox | 8 ++++---- include/GLFW/glfw3.h | 5 +++-- src/cocoa_platform.h | 18 ++++++++++++++++++ src/cocoa_window.m | 38 ++++++++++++++++++++++++++++++++++++-- src/glfw_config.h.in | 1 + src/internal.h | 5 +++++ src/vulkan.c | 5 +++++ 8 files changed, 74 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d8719da..d5439f12 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 c437e350..99934e46 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -268,10 +268,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 d6843f68..4f5f3607 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5776,8 +5776,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 434f46dd..d1b51d6d 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 546f9a82..c8f084d5 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1715,11 +1715,19 @@ const char* _glfwPlatformGetClipboardString(void) 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, @@ -1738,9 +1746,11 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 VkResult err; - VkMacOSSurfaceCreateInfoMVK sci; - PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK; +#if defined(VK_USE_PLATFORM_MACOS_MVK) + VkMacOSSurfaceCreateInfoMVK sci; + + PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK; vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK) vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK"); if (!vkCreateMacOSSurfaceMVK) @@ -1750,6 +1760,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"]; @@ -1776,10 +1800,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 f4876da2..ae058965 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 4c75c9b1..33342d9f 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; @@ -558,7 +559,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 6fd0af2c..f6b07ec8 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 15d91801b7ac3d52779ec7330f2a1c0128fb57df 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 188/942] Cocoa: Select Vulkan surface extension at runtime This mostly just follows the pattern established by X11. Related to #1619. --- 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 d5439f12..8d8719da 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 51d0c668..0fea46e9 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,7 @@ information on what to include when reporting a bug. - [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] Added support for `VK_EXT_metal_surface` (#1619) - [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 @@ -260,6 +261,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 d1b51d6d..e9cd5843 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 c8f084d5..2a24f812 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1715,19 +1715,16 @@ const char* _glfwPlatformGetClipboardString(void) 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, @@ -1745,35 +1742,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"]; @@ -1799,21 +1767,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; - err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface); + if (_glfw.vk.EXT_metal_surface) + { + VkMetalSurfaceCreateInfoEXT sci; -#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; + PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT; + vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT) + vkGetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT"); + if (!vkCreateMetalSurfaceEXT) + { + _glfwInputError(GLFW_API_UNAVAILABLE, + "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension"); + return VK_ERROR_EXTENSION_NOT_PRESENT; + } + + memset(&sci, 0, sizeof(sci)); + sci.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; + sci.pLayer = window->ns.layer; + + 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 ae058965..f4876da2 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 33342d9f..6d7587c8 100644 --- a/src/internal.h +++ b/src/internal.h @@ -559,11 +559,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 f6b07ec8..0bbcb83d 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 7da87aaae7039cbdc132f8f563a2603c5e3c73a1 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 189/942] 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. --- 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 0fea46e9..15593c67 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ information on what to include when reporting a bug. window (#1499) - [Win32] Bugfix: Disabled cursor mode interfered with some non-client actions - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) + - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [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 diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 7e75299a..cbc9462f 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -463,6 +463,32 @@ static GLFWbool initializeTIS(void) @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 e9cd5843..9a979af2 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 0bbcb83d..b5340520 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 562c17d131bd99d92f1166e2a8a42d7af023d122 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 190/942] 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. --- README.md | 1 + src/win32_window.c | 41 +++++++++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 15593c67..c4b57ad0 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,7 @@ information on what to include when reporting a bug. - [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 + - [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 - [Cocoa] Removed dependency on the CoreVideo framework diff --git a/src/win32_window.c b/src/win32_window.c index 3a50c542..79f40d3c 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1934,30 +1934,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; + int i; + const int keys[4][2] = + { + { VK_LSHIFT, GLFW_KEY_LEFT_SHIFT }, + { VK_RSHIFT, GLFW_KEY_RIGHT_SHIFT }, + { VK_LWIN, GLFW_KEY_LEFT_SUPER }, + { VK_RWIN, GLFW_KEY_RIGHT_SUPER } + }; - if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS) + for (i = 0; i < 4; i++) { - 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) - { - 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 a491b0698cc520fb7e77d66e3d335310814cbb86 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 191/942] Win32: Use non-async key state for modifier hack The synchronous key state seems to make more sense in context. --- 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 79f40d3c..d07a0203 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) @@ -1961,12 +1939,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 5f1631cb0e6f3544e9d13e7deb60ff3473a8a3f3 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 192/942] Check scancode before use in glfwGetKeyName --- 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 c4b57ad0..f1aaf849 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,8 @@ information on what to include when reporting a bug. window (#1499) - [Win32] Bugfix: Disabled cursor mode interfered with some non-client actions - [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 - [Cocoa] Removed dependency on the CoreVideo framework diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 2a24f812..e12b5cda 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1516,6 +1516,13 @@ const char* _glfwPlatformGetScancodeName(int scancode) { @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 d07a0203..f99fb7fb 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2026,6 +2026,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 98388bd8..23dc89ad 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 789a2bcb3985a882944f3ae8dc6aa8aa22a23494 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 193/942] 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. --- README.md | 2 + src/win32_window.c | 108 ++++++++++++++++++++++----------------------- 2 files changed, 56 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index f1aaf849..7dc3f333 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,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 - [Cocoa] Removed dependency on the CoreVideo framework diff --git a/src/win32_window.c b/src/win32_window.c index f99fb7fb..798dd42d 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) }; @@ -726,13 +675,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 190673e77965b043bbb76020e5557d53c9d80cda 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 194/942] Win32: Add matching comment --- src/win32_window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/win32_window.c b/src/win32_window.c index 798dd42d..0ae0998a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1918,6 +1918,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 d862d56acb9707c2c88a006a18b0353308995032 Mon Sep 17 00:00:00 2001 From: Crunkle Date: Tue, 14 Jan 2020 00:49:04 +0000 Subject: [PATCH 195/942] Fix docs install condition Closes #1624. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d8719da..eaae85a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -351,7 +351,7 @@ if (GLFW_INSTALL) install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") - if (GLFW_BUILD_DOCS) + if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS) install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html" DESTINATION "${CMAKE_INSTALL_DOCDIR}") endif() From 65cfe743af474a3c63304779c743dc808ae05091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 16 Jan 2020 17:35:11 +0100 Subject: [PATCH 196/942] Add credit Related to #1624. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7dc3f333..251eaaa8 100644 --- a/README.md +++ b/README.md @@ -359,6 +359,7 @@ skills. - Paul Sultana - Nathan Sweet - TTK-Bandit + - Jared Tiala - Sergey Tikhomirov - Arthur Tombs - Ioannis Tsakpinis From a5e5b782c7c7eaa71a1d60e71934724240ae2ab6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 21 Aug 2018 13:04:52 +0530 Subject: [PATCH 197/942] X11: Fix queries crashing if monitor disconnected Merged from downstream kovidgoyal/glfw. First of many. Related to #1602. --- 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 4d3e1a94..809b93e4 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 13479ed27dd94e4196205b173c6a2ab104ed21f5 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 198/942] Update changelog and add credit Related to #1602. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 251eaaa8..9ecaab45 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Monitor physical dimensions could be reported as zero mm - [X11] Bugfix: Window position events were not emitted during resizing (#1613) - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM + - [X11] Bugfix: Querying a disconnected monitor could segfault (#1602) - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled @@ -275,6 +276,7 @@ skills. - Rokas Kupstys - Konstantin Käfer - Eric Larson + - Francis Lecavalier - Robin Leffmann - Glenn Lewis - Shane Liesegang From 46c7c1cdffbc1753eea127b6252d0c5e018b82b1 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 199/942] Remove AppVeyor skip commits setting --- .appveyor.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2f4532eb..a21829a6 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 d973acc123826666ecc9e6fd475682e3d84c54a6 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 200/942] 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. --- README.md | 1 + docs/build.dox | 122 ++++++++++++++++--------------------------------- 2 files changed, 40 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index 9ecaab45..c543d25f 100644 --- a/README.md +++ b/README.md @@ -285,6 +285,7 @@ skills. - Eyal Lotem - Aaron Loucks - Luflosi + - lukect - Tristam MacDonald - Hans Mackowiak - Дмитри Малышев diff --git a/docs/build.dox b/docs/build.dox index 7c3b8ae2..b22e5f0c 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 @@ -187,51 +183,38 @@ With a few changes to your `CMakeLists.txt` you can have the GLFW source tree built along with your application. 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. +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 @@ -247,44 +230,30 @@ find_package(glfw3 3.4 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 @@ -299,42 +268,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. +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 --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. - -@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 @@ -368,9 +326,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 76406c7894912125afae59e6e5be00222ba10b48 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 6 Feb 2020 09:02:14 +0100 Subject: [PATCH 201/942] Mention that xdg-shell is mandatory on Wayland --- docs/compat.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/compat.dox b/docs/compat.dox index 99934e46..8aba6698 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -111,7 +111,7 @@ has been configured in the compositor. GLFW uses the [xdg-shell protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/xdg-shell/xdg-shell.xml) to provide better window management. This protocol is part of -wayland-protocols 1.12, and mandatory at build time. +wayland-protocols 1.12, and is mandatory for GLFW to display a window. GLFW uses the [relative pointer protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/unstable/relative-pointer/relative-pointer-unstable-v1.xml) From 40c7e471e322f7c2e727465a1b6b53331762a5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 20 Jan 2020 16:33:33 +0100 Subject: [PATCH 202/942] Move more non-source template files to CMake dir --- {src => CMake}/glfw3.pc.in | 0 {src => CMake}/glfw3Config.cmake.in | 0 CMakeLists.txt | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename {src => CMake}/glfw3.pc.in (100%) rename {src => CMake}/glfw3Config.cmake.in (100%) diff --git a/src/glfw3.pc.in b/CMake/glfw3.pc.in similarity index 100% rename from src/glfw3.pc.in rename to CMake/glfw3.pc.in diff --git a/src/glfw3Config.cmake.in b/CMake/glfw3Config.cmake.in similarity index 100% rename from src/glfw3Config.cmake.in rename to CMake/glfw3Config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index eaae85a8..b8057153 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -305,7 +305,7 @@ include(CMakePackageConfigHelpers) set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/glfw3") -configure_package_config_file(src/glfw3Config.cmake.in +configure_package_config_file(CMake/glfw3Config.cmake.in src/glfw3Config.cmake INSTALL_DESTINATION "${GLFW_CONFIG_PATH}" NO_CHECK_REQUIRED_COMPONENTS_MACRO) @@ -314,7 +314,7 @@ write_basic_package_version_file(src/glfw3ConfigVersion.cmake VERSION ${GLFW_VERSION} COMPATIBILITY SameMajorVersion) -configure_file(src/glfw3.pc.in src/glfw3.pc @ONLY) +configure_file(CMake/glfw3.pc.in src/glfw3.pc @ONLY) #-------------------------------------------------------------------- # Add subdirectories From d1ae7bac608e082ef7dad302811dc4cf3fdf3ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 10 Feb 2020 17:44:34 +0100 Subject: [PATCH 203/942] Put docs target in GLFW3 folder --- docs/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index df9e2147..2347858e 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -30,3 +30,5 @@ add_custom_target(docs ALL "${DOXYGEN_EXECUTABLE}" WORKING_DIRECTORY "${GLFW_BINARY_DIR}/docs" COMMENT "Generating HTML documentation" VERBATIM) +set_target_properties(docs PROPERTIES FOLDER "GLFW3") + From 0c27ed1d0ef36672f0ef28d86bf8e108cc6e379d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 24 Jan 2020 09:34:54 +0100 Subject: [PATCH 204/942] X11: Fix setting the clipboard string to itself --- src/x11_window.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/x11_window.c b/src/x11_window.c index 23dc89ad..89356671 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2997,8 +2997,9 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) void _glfwPlatformSetClipboardString(const char* string) { + char* copy = _glfw_strdup(string); free(_glfw.x11.clipboardString); - _glfw.x11.clipboardString = _glfw_strdup(string); + _glfw.x11.clipboardString = copy; XSetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD, From a0a5cc57dff620f97428168a2580714bebc22381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Dec 2019 13:19:37 +0100 Subject: [PATCH 205/942] X11: Make libX11 dynamically loaded This completes the dynamic loading of all X11 libraries in preparation for run-time platform selection. --- CMakeLists.txt | 3 - src/x11_init.c | 212 +++++++++++++++++++++++++++++++- src/x11_platform.h | 297 +++++++++++++++++++++++++++++++++++++++++++++ src/x11_window.c | 2 +- 4 files changed, 508 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8057153..95753ebc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,11 +195,8 @@ if (_GLFW_X11) find_package(X11 REQUIRED) - list(APPEND glfw_PKG_DEPS "x11") - # Set up library and include paths list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}") - list(APPEND glfw_LIBRARIES "${X11_X11_LIB}") # Check for XRandR (modern resolution switching and gamma control) if (NOT X11_Xrandr_INCLUDE_PATH) diff --git a/src/x11_init.c b/src/x11_init.c index 2b7bc7f1..eb440711 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -29,8 +29,6 @@ #include "internal.h" -#include - #include #include #include @@ -948,6 +946,210 @@ int _glfwPlatformInit(void) setlocale(LC_CTYPE, ""); #endif +#if defined(__CYGWIN__) + _glfw.x11.xlib.handle = _glfw_dlopen("libX11-6.so"); +#else + _glfw.x11.xlib.handle = _glfw_dlopen("libX11.so.6"); +#endif + if (!_glfw.x11.xlib.handle) + { + _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib"); + return GLFW_FALSE; + } + + _glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint) + _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocClassHint"); + _glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints) + _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocSizeHints"); + _glfw.x11.xlib.AllocWMHints = (PFN_XAllocWMHints) + _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocWMHints"); + _glfw.x11.xlib.ChangeProperty = (PFN_XChangeProperty) + _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeProperty"); + _glfw.x11.xlib.ChangeWindowAttributes = (PFN_XChangeWindowAttributes) + _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeWindowAttributes"); + _glfw.x11.xlib.CheckIfEvent = (PFN_XCheckIfEvent) + _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckIfEvent"); + _glfw.x11.xlib.CheckTypedWindowEvent = (PFN_XCheckTypedWindowEvent) + _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent"); + _glfw.x11.xlib.CloseDisplay = (PFN_XCloseDisplay) + _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseDisplay"); + _glfw.x11.xlib.CloseIM = (PFN_XCloseIM) + _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseIM"); + _glfw.x11.xlib.ConvertSelection = (PFN_XConvertSelection) + _glfw_dlsym(_glfw.x11.xlib.handle, "XConvertSelection"); + _glfw.x11.xlib.CreateColormap = (PFN_XCreateColormap) + _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateColormap"); + _glfw.x11.xlib.CreateFontCursor = (PFN_XCreateFontCursor) + _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateFontCursor"); + _glfw.x11.xlib.CreateIC = (PFN_XCreateIC) + _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateIC"); + _glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow) + _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateWindow"); + _glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor) + _glfw_dlsym(_glfw.x11.xlib.handle, "XDefineCursor"); + _glfw.x11.xlib.DeleteContext = (PFN_XDeleteContext) + _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteContext"); + _glfw.x11.xlib.DeleteProperty = (PFN_XDeleteProperty) + _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteProperty"); + _glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC) + _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyIC"); + _glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow) + _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyWindow"); + _glfw.x11.xlib.EventsQueued = (PFN_XEventsQueued) + _glfw_dlsym(_glfw.x11.xlib.handle, "XEventsQueued"); + _glfw.x11.xlib.FilterEvent = (PFN_XFilterEvent) + _glfw_dlsym(_glfw.x11.xlib.handle, "XFilterEvent"); + _glfw.x11.xlib.FindContext = (PFN_XFindContext) + _glfw_dlsym(_glfw.x11.xlib.handle, "XFindContext"); + _glfw.x11.xlib.Flush = (PFN_XFlush) + _glfw_dlsym(_glfw.x11.xlib.handle, "XFlush"); + _glfw.x11.xlib.Free = (PFN_XFree) + _glfw_dlsym(_glfw.x11.xlib.handle, "XFree"); + _glfw.x11.xlib.FreeColormap = (PFN_XFreeColormap) + _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeColormap"); + _glfw.x11.xlib.FreeCursor = (PFN_XFreeCursor) + _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeCursor"); + _glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData) + _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeEventData"); + _glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetErrorText"); + _glfw.x11.xlib.GetEventData = (PFN_XGetEventData) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetEventData"); + _glfw.x11.xlib.GetICValues = (PFN_XGetICValues) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetICValues"); + _glfw.x11.xlib.GetIMValues = (PFN_XGetIMValues) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetIMValues"); + _glfw.x11.xlib.GetInputFocus = (PFN_XGetInputFocus) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetInputFocus"); + _glfw.x11.xlib.GetKeyboardMapping = (PFN_XGetKeyboardMapping) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetKeyboardMapping"); + _glfw.x11.xlib.GetScreenSaver = (PFN_XGetScreenSaver) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetScreenSaver"); + _glfw.x11.xlib.GetSelectionOwner = (PFN_XGetSelectionOwner) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetSelectionOwner"); + _glfw.x11.xlib.GetVisualInfo = (PFN_XGetVisualInfo) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetVisualInfo"); + _glfw.x11.xlib.GetWMNormalHints = (PFN_XGetWMNormalHints) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWMNormalHints"); + _glfw.x11.xlib.GetWindowAttributes = (PFN_XGetWindowAttributes) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowAttributes"); + _glfw.x11.xlib.GetWindowProperty = (PFN_XGetWindowProperty) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowProperty"); + _glfw.x11.xlib.GrabPointer = (PFN_XGrabPointer) + _glfw_dlsym(_glfw.x11.xlib.handle, "XGrabPointer"); + _glfw.x11.xlib.IconifyWindow = (PFN_XIconifyWindow) + _glfw_dlsym(_glfw.x11.xlib.handle, "XIconifyWindow"); + _glfw.x11.xlib.InitThreads = (PFN_XInitThreads) + _glfw_dlsym(_glfw.x11.xlib.handle, "XInitThreads"); + _glfw.x11.xlib.InternAtom = (PFN_XInternAtom) + _glfw_dlsym(_glfw.x11.xlib.handle, "XInternAtom"); + _glfw.x11.xlib.LookupString = (PFN_XLookupString) + _glfw_dlsym(_glfw.x11.xlib.handle, "XLookupString"); + _glfw.x11.xlib.MapRaised = (PFN_XMapRaised) + _glfw_dlsym(_glfw.x11.xlib.handle, "XMapRaised"); + _glfw.x11.xlib.MapWindow = (PFN_XMapWindow) + _glfw_dlsym(_glfw.x11.xlib.handle, "XMapWindow"); + _glfw.x11.xlib.MoveResizeWindow = (PFN_XMoveResizeWindow) + _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveResizeWindow"); + _glfw.x11.xlib.MoveWindow = (PFN_XMoveWindow) + _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveWindow"); + _glfw.x11.xlib.NextEvent = (PFN_XNextEvent) + _glfw_dlsym(_glfw.x11.xlib.handle, "XNextEvent"); + _glfw.x11.xlib.OpenDisplay = (PFN_XOpenDisplay) + _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenDisplay"); + _glfw.x11.xlib.OpenIM = (PFN_XOpenIM) + _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenIM"); + _glfw.x11.xlib.PeekEvent = (PFN_XPeekEvent) + _glfw_dlsym(_glfw.x11.xlib.handle, "XPeekEvent"); + _glfw.x11.xlib.Pending = (PFN_XPending) + _glfw_dlsym(_glfw.x11.xlib.handle, "XPending"); + _glfw.x11.xlib.QueryExtension = (PFN_XQueryExtension) + _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryExtension"); + _glfw.x11.xlib.QueryPointer = (PFN_XQueryPointer) + _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryPointer"); + _glfw.x11.xlib.RaiseWindow = (PFN_XRaiseWindow) + _glfw_dlsym(_glfw.x11.xlib.handle, "XRaiseWindow"); + _glfw.x11.xlib.ResizeWindow = (PFN_XResizeWindow) + _glfw_dlsym(_glfw.x11.xlib.handle, "XResizeWindow"); + _glfw.x11.xlib.ResourceManagerString = (PFN_XResourceManagerString) + _glfw_dlsym(_glfw.x11.xlib.handle, "XResourceManagerString"); + _glfw.x11.xlib.SaveContext = (PFN_XSaveContext) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSaveContext"); + _glfw.x11.xlib.SelectInput = (PFN_XSelectInput) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSelectInput"); + _glfw.x11.xlib.SendEvent = (PFN_XSendEvent) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSendEvent"); + _glfw.x11.xlib.SetClassHint = (PFN_XSetClassHint) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetClassHint"); + _glfw.x11.xlib.SetErrorHandler = (PFN_XSetErrorHandler) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetErrorHandler"); + _glfw.x11.xlib.SetICFocus = (PFN_XSetICFocus) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetICFocus"); + _glfw.x11.xlib.SetInputFocus = (PFN_XSetInputFocus) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetInputFocus"); + _glfw.x11.xlib.SetLocaleModifiers = (PFN_XSetLocaleModifiers) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetLocaleModifiers"); + _glfw.x11.xlib.SetScreenSaver = (PFN_XSetScreenSaver) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetScreenSaver"); + _glfw.x11.xlib.SetSelectionOwner = (PFN_XSetSelectionOwner) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetSelectionOwner"); + _glfw.x11.xlib.SetWMHints = (PFN_XSetWMHints) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMHints"); + _glfw.x11.xlib.SetWMNormalHints = (PFN_XSetWMNormalHints) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMNormalHints"); + _glfw.x11.xlib.SetWMProtocols = (PFN_XSetWMProtocols) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMProtocols"); + _glfw.x11.xlib.SupportsLocale = (PFN_XSupportsLocale) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSupportsLocale"); + _glfw.x11.xlib.Sync = (PFN_XSync) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSync"); + _glfw.x11.xlib.TranslateCoordinates = (PFN_XTranslateCoordinates) + _glfw_dlsym(_glfw.x11.xlib.handle, "XTranslateCoordinates"); + _glfw.x11.xlib.UndefineCursor = (PFN_XUndefineCursor) + _glfw_dlsym(_glfw.x11.xlib.handle, "XUndefineCursor"); + _glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer) + _glfw_dlsym(_glfw.x11.xlib.handle, "XUngrabPointer"); + _glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow) + _glfw_dlsym(_glfw.x11.xlib.handle, "XUnmapWindow"); + _glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus) + _glfw_dlsym(_glfw.x11.xlib.handle, "XUnsetICFocus"); + _glfw.x11.xlib.VisualIDFromVisual = (PFN_XVisualIDFromVisual) + _glfw_dlsym(_glfw.x11.xlib.handle, "XVisualIDFromVisual"); + _glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer) + _glfw_dlsym(_glfw.x11.xlib.handle, "XWarpPointer"); + _glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard) + _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeKeyboard"); + _glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames) + _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeNames"); + _glfw.x11.xkb.GetMap = (PFN_XkbGetMap) + _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetMap"); + _glfw.x11.xkb.GetNames = (PFN_XkbGetNames) + _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetNames"); + _glfw.x11.xkb.GetState = (PFN_XkbGetState) + _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetState"); + _glfw.x11.xkb.KeycodeToKeysym = (PFN_XkbKeycodeToKeysym) + _glfw_dlsym(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym"); + _glfw.x11.xkb.QueryExtension = (PFN_XkbQueryExtension) + _glfw_dlsym(_glfw.x11.xlib.handle, "XkbQueryExtension"); + _glfw.x11.xkb.SelectEventDetails = (PFN_XkbSelectEventDetails) + _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSelectEventDetails"); + _glfw.x11.xkb.SetDetectableAutoRepeat = (PFN_XkbSetDetectableAutoRepeat) + _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat"); + _glfw.x11.xrm.DestroyDatabase = (PFN_XrmDestroyDatabase) + _glfw_dlsym(_glfw.x11.xlib.handle, "XrmDestroyDatabase"); + _glfw.x11.xrm.GetResource = (PFN_XrmGetResource) + _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetResource"); + _glfw.x11.xrm.GetStringDatabase = (PFN_XrmGetStringDatabase) + _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetStringDatabase"); + _glfw.x11.xrm.Initialize = (PFN_XrmInitialize) + _glfw_dlsym(_glfw.x11.xlib.handle, "XrmInitialize"); + _glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark) + _glfw_dlsym(_glfw.x11.xlib.handle, "XrmUniqueQuark"); + _glfw.x11.xlib.utf8LookupString = (PFN_Xutf8LookupString) + _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8LookupString"); + _glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties) + _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8SetWMProperties"); + XInitThreads(); XrmInitialize(); @@ -1092,6 +1294,12 @@ void _glfwPlatformTerminate(void) #if defined(__linux__) _glfwTerminateJoysticksLinux(); #endif + + if (_glfw.x11.xlib.handle) + { + _glfw_dlclose(_glfw.x11.xlib.handle); + _glfw.x11.xlib.handle = NULL; + } } const char* _glfwPlatformGetVersionString(void) diff --git a/src/x11_platform.h b/src/x11_platform.h index 04c46647..d6b345dd 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -33,6 +33,7 @@ #include #include #include +#include #include // The XRandR extension provides mode setting and gamma control @@ -47,6 +48,199 @@ // The XInput extension provides raw mouse motion input #include +typedef XClassHint* (* PFN_XAllocClassHint)(void); +typedef XSizeHints* (* PFN_XAllocSizeHints)(void); +typedef XWMHints* (* PFN_XAllocWMHints)(void); +typedef int (* PFN_XChangeProperty)(Display*,Window,Atom,Atom,int,int,const unsigned char*,int); +typedef int (* PFN_XChangeWindowAttributes)(Display*,Window,unsigned long,XSetWindowAttributes*); +typedef Bool (* PFN_XCheckIfEvent)(Display*,XEvent*,Bool(*)(Display*,XEvent*,XPointer),XPointer); +typedef Bool (* PFN_XCheckTypedWindowEvent)(Display*,Window,int,XEvent*); +typedef int (* PFN_XCloseDisplay)(Display*); +typedef Status (* PFN_XCloseIM)(XIM); +typedef int (* PFN_XConvertSelection)(Display*,Atom,Atom,Atom,Window,Time); +typedef Colormap (* PFN_XCreateColormap)(Display*,Window,Visual*,int); +typedef Cursor (* PFN_XCreateFontCursor)(Display*,unsigned int); +typedef XIC (* PFN_XCreateIC)(XIM,...); +typedef Window (* PFN_XCreateWindow)(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,int,unsigned int,Visual*,unsigned long,XSetWindowAttributes*); +typedef int (* PFN_XDefineCursor)(Display*,Window,Cursor); +typedef int (* PFN_XDeleteContext)(Display*,XID,XContext); +typedef int (* PFN_XDeleteProperty)(Display*,Window,Atom); +typedef void (* PFN_XDestroyIC)(XIC); +typedef int (* PFN_XDestroyWindow)(Display*,Window); +typedef int (* PFN_XEventsQueued)(Display*,int); +typedef Bool (* PFN_XFilterEvent)(XEvent*,Window); +typedef int (* PFN_XFindContext)(Display*,XID,XContext,XPointer*); +typedef int (* PFN_XFlush)(Display*); +typedef int (* PFN_XFree)(void*); +typedef int (* PFN_XFreeColormap)(Display*,Colormap); +typedef int (* PFN_XFreeCursor)(Display*,Cursor); +typedef void (* PFN_XFreeEventData)(Display*,XGenericEventCookie*); +typedef int (* PFN_XGetErrorText)(Display*,int,char*,int); +typedef Bool (* PFN_XGetEventData)(Display*,XGenericEventCookie*); +typedef char* (* PFN_XGetICValues)(XIC,...); +typedef char* (* PFN_XGetIMValues)(XIM,...); +typedef int (* PFN_XGetInputFocus)(Display*,Window*,int*); +typedef KeySym* (* PFN_XGetKeyboardMapping)(Display*,KeyCode,int,int*); +typedef int (* PFN_XGetScreenSaver)(Display*,int*,int*,int*,int*); +typedef Window (* PFN_XGetSelectionOwner)(Display*,Atom); +typedef XVisualInfo* (* PFN_XGetVisualInfo)(Display*,long,XVisualInfo*,int*); +typedef Status (* PFN_XGetWMNormalHints)(Display*,Window,XSizeHints*,long*); +typedef Status (* PFN_XGetWindowAttributes)(Display*,Window,XWindowAttributes*); +typedef int (* PFN_XGetWindowProperty)(Display*,Window,Atom,long,long,Bool,Atom,Atom*,int*,unsigned long*,unsigned long*,unsigned char**); +typedef int (* PFN_XGrabPointer)(Display*,Window,Bool,unsigned int,int,int,Window,Cursor,Time); +typedef Status (* PFN_XIconifyWindow)(Display*,Window,int); +typedef Status (* PFN_XInitThreads)(void); +typedef Atom (* PFN_XInternAtom)(Display*,const char*,Bool); +typedef int (* PFN_XLookupString)(XKeyEvent*,char*,int,KeySym*,XComposeStatus*); +typedef int (* PFN_XMapRaised)(Display*,Window); +typedef int (* PFN_XMapWindow)(Display*,Window); +typedef int (* PFN_XMoveResizeWindow)(Display*,Window,int,int,unsigned int,unsigned int); +typedef int (* PFN_XMoveWindow)(Display*,Window,int,int); +typedef int (* PFN_XNextEvent)(Display*,XEvent*); +typedef Display* (* PFN_XOpenDisplay)(const char*); +typedef XIM (* PFN_XOpenIM)(Display*,XrmDatabase*,char*,char*); +typedef int (* PFN_XPeekEvent)(Display*,XEvent*); +typedef int (* PFN_XPending)(Display*); +typedef Bool (* PFN_XQueryExtension)(Display*,const char*,int*,int*,int*); +typedef Bool (* PFN_XQueryPointer)(Display*,Window,Window*,Window*,int*,int*,int*,int*,unsigned int*); +typedef int (* PFN_XRaiseWindow)(Display*,Window); +typedef int (* PFN_XResizeWindow)(Display*,Window,unsigned int,unsigned int); +typedef char* (* PFN_XResourceManagerString)(Display*); +typedef int (* PFN_XSaveContext)(Display*,XID,XContext,const char*); +typedef int (* PFN_XSelectInput)(Display*,Window,long); +typedef Status (* PFN_XSendEvent)(Display*,Window,Bool,long,XEvent*); +typedef int (* PFN_XSetClassHint)(Display*,Window,XClassHint*); +typedef XErrorHandler (* PFN_XSetErrorHandler)(XErrorHandler); +typedef void (* PFN_XSetICFocus)(XIC); +typedef int (* PFN_XSetInputFocus)(Display*,Window,int,Time); +typedef char* (* PFN_XSetLocaleModifiers)(const char*); +typedef int (* PFN_XSetScreenSaver)(Display*,int,int,int,int); +typedef int (* PFN_XSetSelectionOwner)(Display*,Atom,Window,Time); +typedef int (* PFN_XSetWMHints)(Display*,Window,XWMHints*); +typedef void (* PFN_XSetWMNormalHints)(Display*,Window,XSizeHints*); +typedef Status (* PFN_XSetWMProtocols)(Display*,Window,Atom*,int); +typedef Bool (* PFN_XSupportsLocale)(void); +typedef int (* PFN_XSync)(Display*,Bool); +typedef Bool (* PFN_XTranslateCoordinates)(Display*,Window,Window,int,int,int*,int*,Window*); +typedef int (* PFN_XUndefineCursor)(Display*,Window); +typedef int (* PFN_XUngrabPointer)(Display*,Time); +typedef int (* PFN_XUnmapWindow)(Display*,Window); +typedef void (* PFN_XUnsetICFocus)(XIC); +typedef VisualID (* PFN_XVisualIDFromVisual)(Visual*); +typedef int (* PFN_XWarpPointer)(Display*,Window,Window,int,int,unsigned int,unsigned int,int,int); +typedef void (* PFN_XkbFreeKeyboard)(XkbDescPtr,unsigned int,Bool); +typedef void (* PFN_XkbFreeNames)(XkbDescPtr,unsigned int,Bool); +typedef XkbDescPtr (* PFN_XkbGetMap)(Display*,unsigned int,unsigned int); +typedef Status (* PFN_XkbGetNames)(Display*,unsigned int,XkbDescPtr); +typedef Status (* PFN_XkbGetState)(Display*,unsigned int,XkbStatePtr); +typedef KeySym (* PFN_XkbKeycodeToKeysym)(Display*,KeyCode,int,int); +typedef Bool (* PFN_XkbQueryExtension)(Display*,int*,int*,int*,int*,int*); +typedef Bool (* PFN_XkbSelectEventDetails)(Display*,unsigned int,unsigned int,unsigned long,unsigned long); +typedef Bool (* PFN_XkbSetDetectableAutoRepeat)(Display*,Bool,Bool*); +typedef void (* PFN_XrmDestroyDatabase)(XrmDatabase); +typedef Bool (* PFN_XrmGetResource)(XrmDatabase,const char*,const char*,char**,XrmValue*); +typedef XrmDatabase (* PFN_XrmGetStringDatabase)(const char*); +typedef void (* PFN_XrmInitialize)(void); +typedef XrmQuark (* PFN_XrmUniqueQuark)(void); +typedef int (* PFN_Xutf8LookupString)(XIC,XKeyPressedEvent*,char*,int,KeySym*,Status*); +typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char*,char**,int,XSizeHints*,XWMHints*,XClassHint*); +#define XAllocClassHint _glfw.x11.xlib.AllocClassHint +#define XAllocSizeHints _glfw.x11.xlib.AllocSizeHints +#define XAllocWMHints _glfw.x11.xlib.AllocWMHints +#define XChangeProperty _glfw.x11.xlib.ChangeProperty +#define XChangeWindowAttributes _glfw.x11.xlib.ChangeWindowAttributes +#define XCheckIfEvent _glfw.x11.xlib.CheckIfEvent +#define XCheckTypedWindowEvent _glfw.x11.xlib.CheckTypedWindowEvent +#define XCloseDisplay _glfw.x11.xlib.CloseDisplay +#define XCloseIM _glfw.x11.xlib.CloseIM +#define XConvertSelection _glfw.x11.xlib.ConvertSelection +#define XCreateColormap _glfw.x11.xlib.CreateColormap +#define XCreateFontCursor _glfw.x11.xlib.CreateFontCursor +#define XCreateIC _glfw.x11.xlib.CreateIC +#define XCreateWindow _glfw.x11.xlib.CreateWindow +#define XDefineCursor _glfw.x11.xlib.DefineCursor +#define XDeleteContext _glfw.x11.xlib.DeleteContext +#define XDeleteProperty _glfw.x11.xlib.DeleteProperty +#define XDestroyIC _glfw.x11.xlib.DestroyIC +#define XDestroyWindow _glfw.x11.xlib.DestroyWindow +#define XEventsQueued _glfw.x11.xlib.EventsQueued +#define XFilterEvent _glfw.x11.xlib.FilterEvent +#define XFindContext _glfw.x11.xlib.FindContext +#define XFlush _glfw.x11.xlib.Flush +#define XFree _glfw.x11.xlib.Free +#define XFreeColormap _glfw.x11.xlib.FreeColormap +#define XFreeCursor _glfw.x11.xlib.FreeCursor +#define XFreeEventData _glfw.x11.xlib.FreeEventData +#define XGetErrorText _glfw.x11.xlib.GetErrorText +#define XGetEventData _glfw.x11.xlib.GetEventData +#define XGetICValues _glfw.x11.xlib.GetICValues +#define XGetIMValues _glfw.x11.xlib.GetIMValues +#define XGetInputFocus _glfw.x11.xlib.GetInputFocus +#define XGetKeyboardMapping _glfw.x11.xlib.GetKeyboardMapping +#define XGetScreenSaver _glfw.x11.xlib.GetScreenSaver +#define XGetSelectionOwner _glfw.x11.xlib.GetSelectionOwner +#define XGetVisualInfo _glfw.x11.xlib.GetVisualInfo +#define XGetWMNormalHints _glfw.x11.xlib.GetWMNormalHints +#define XGetWindowAttributes _glfw.x11.xlib.GetWindowAttributes +#define XGetWindowProperty _glfw.x11.xlib.GetWindowProperty +#define XGrabPointer _glfw.x11.xlib.GrabPointer +#define XIconifyWindow _glfw.x11.xlib.IconifyWindow +#define XInitThreads _glfw.x11.xlib.InitThreads +#define XInternAtom _glfw.x11.xlib.InternAtom +#define XLookupString _glfw.x11.xlib.LookupString +#define XMapRaised _glfw.x11.xlib.MapRaised +#define XMapWindow _glfw.x11.xlib.MapWindow +#define XMoveResizeWindow _glfw.x11.xlib.MoveResizeWindow +#define XMoveWindow _glfw.x11.xlib.MoveWindow +#define XNextEvent _glfw.x11.xlib.NextEvent +#define XOpenDisplay _glfw.x11.xlib.OpenDisplay +#define XOpenIM _glfw.x11.xlib.OpenIM +#define XPeekEvent _glfw.x11.xlib.PeekEvent +#define XPending _glfw.x11.xlib.Pending +#define XQueryExtension _glfw.x11.xlib.QueryExtension +#define XQueryPointer _glfw.x11.xlib.QueryPointer +#define XRaiseWindow _glfw.x11.xlib.RaiseWindow +#define XResizeWindow _glfw.x11.xlib.ResizeWindow +#define XResourceManagerString _glfw.x11.xlib.ResourceManagerString +#define XSaveContext _glfw.x11.xlib.SaveContext +#define XSelectInput _glfw.x11.xlib.SelectInput +#define XSendEvent _glfw.x11.xlib.SendEvent +#define XSetClassHint _glfw.x11.xlib.SetClassHint +#define XSetErrorHandler _glfw.x11.xlib.SetErrorHandler +#define XSetICFocus _glfw.x11.xlib.SetICFocus +#define XSetInputFocus _glfw.x11.xlib.SetInputFocus +#define XSetLocaleModifiers _glfw.x11.xlib.SetLocaleModifiers +#define XSetScreenSaver _glfw.x11.xlib.SetScreenSaver +#define XSetSelectionOwner _glfw.x11.xlib.SetSelectionOwner +#define XSetWMHints _glfw.x11.xlib.SetWMHints +#define XSetWMNormalHints _glfw.x11.xlib.SetWMNormalHints +#define XSetWMProtocols _glfw.x11.xlib.SetWMProtocols +#define XSupportsLocale _glfw.x11.xlib.SupportsLocale +#define XSync _glfw.x11.xlib.Sync +#define XTranslateCoordinates _glfw.x11.xlib.TranslateCoordinates +#define XUndefineCursor _glfw.x11.xlib.UndefineCursor +#define XUngrabPointer _glfw.x11.xlib.UngrabPointer +#define XUnmapWindow _glfw.x11.xlib.UnmapWindow +#define XUnsetICFocus _glfw.x11.xlib.UnsetICFocus +#define XVisualIDFromVisual _glfw.x11.xlib.VisualIDFromVisual +#define XWarpPointer _glfw.x11.xlib.WarpPointer +#define XkbFreeKeyboard _glfw.x11.xkb.FreeKeyboard +#define XkbFreeNames _glfw.x11.xkb.FreeNames +#define XkbGetMap _glfw.x11.xkb.GetMap +#define XkbGetNames _glfw.x11.xkb.GetNames +#define XkbGetState _glfw.x11.xkb.GetState +#define XkbKeycodeToKeysym _glfw.x11.xkb.KeycodeToKeysym +#define XkbQueryExtension _glfw.x11.xkb.QueryExtension +#define XkbSelectEventDetails _glfw.x11.xkb.SelectEventDetails +#define XkbSetDetectableAutoRepeat _glfw.x11.xkb.SetDetectableAutoRepeat +#define XrmDestroyDatabase _glfw.x11.xrm.DestroyDatabase +#define XrmGetResource _glfw.x11.xrm.GetResource +#define XrmGetStringDatabase _glfw.x11.xrm.GetStringDatabase +#define XrmInitialize _glfw.x11.xrm.Initialize +#define XrmUniqueQuark _glfw.x11.xrm.UniqueQuark +#define Xutf8LookupString _glfw.x11.xlib.utf8LookupString +#define Xutf8SetWMProperties _glfw.x11.xlib.utf8SetWMProperties + typedef XRRCrtcGamma* (* PFN_XRRAllocGamma)(int); typedef void (* PFN_XRRFreeCrtcInfo)(XRRCrtcInfo*); typedef void (* PFN_XRRFreeGamma)(XRRCrtcGamma*); @@ -301,6 +495,100 @@ typedef struct _GLFWlibraryX11 Atom ATOM_PAIR; Atom GLFW_SELECTION; + struct { + void* handle; + PFN_XAllocClassHint AllocClassHint; + PFN_XAllocSizeHints AllocSizeHints; + PFN_XAllocWMHints AllocWMHints; + PFN_XChangeProperty ChangeProperty; + PFN_XChangeWindowAttributes ChangeWindowAttributes; + PFN_XCheckIfEvent CheckIfEvent; + PFN_XCheckTypedWindowEvent CheckTypedWindowEvent; + PFN_XCloseDisplay CloseDisplay; + PFN_XCloseIM CloseIM; + PFN_XConvertSelection ConvertSelection; + PFN_XCreateColormap CreateColormap; + PFN_XCreateFontCursor CreateFontCursor; + PFN_XCreateIC CreateIC; + PFN_XCreateWindow CreateWindow; + PFN_XDefineCursor DefineCursor; + PFN_XDeleteContext DeleteContext; + PFN_XDeleteProperty DeleteProperty; + PFN_XDestroyIC DestroyIC; + PFN_XDestroyWindow DestroyWindow; + PFN_XEventsQueued EventsQueued; + PFN_XFilterEvent FilterEvent; + PFN_XFindContext FindContext; + PFN_XFlush Flush; + PFN_XFree Free; + PFN_XFreeColormap FreeColormap; + PFN_XFreeCursor FreeCursor; + PFN_XFreeEventData FreeEventData; + PFN_XGetErrorText GetErrorText; + PFN_XGetEventData GetEventData; + PFN_XGetICValues GetICValues; + PFN_XGetIMValues GetIMValues; + PFN_XGetInputFocus GetInputFocus; + PFN_XGetKeyboardMapping GetKeyboardMapping; + PFN_XGetScreenSaver GetScreenSaver; + PFN_XGetSelectionOwner GetSelectionOwner; + PFN_XGetVisualInfo GetVisualInfo; + PFN_XGetWMNormalHints GetWMNormalHints; + PFN_XGetWindowAttributes GetWindowAttributes; + PFN_XGetWindowProperty GetWindowProperty; + PFN_XGrabPointer GrabPointer; + PFN_XIconifyWindow IconifyWindow; + PFN_XInitThreads InitThreads; + PFN_XInternAtom InternAtom; + PFN_XLookupString LookupString; + PFN_XMapRaised MapRaised; + PFN_XMapWindow MapWindow; + PFN_XMoveResizeWindow MoveResizeWindow; + PFN_XMoveWindow MoveWindow; + PFN_XNextEvent NextEvent; + PFN_XOpenDisplay OpenDisplay; + PFN_XOpenIM OpenIM; + PFN_XPeekEvent PeekEvent; + PFN_XPending Pending; + PFN_XQueryExtension QueryExtension; + PFN_XQueryPointer QueryPointer; + PFN_XRaiseWindow RaiseWindow; + PFN_XResizeWindow ResizeWindow; + PFN_XResourceManagerString ResourceManagerString; + PFN_XSaveContext SaveContext; + PFN_XSelectInput SelectInput; + PFN_XSendEvent SendEvent; + PFN_XSetClassHint SetClassHint; + PFN_XSetErrorHandler SetErrorHandler; + PFN_XSetICFocus SetICFocus; + PFN_XSetInputFocus SetInputFocus; + PFN_XSetLocaleModifiers SetLocaleModifiers; + PFN_XSetScreenSaver SetScreenSaver; + PFN_XSetSelectionOwner SetSelectionOwner; + PFN_XSetWMHints SetWMHints; + PFN_XSetWMNormalHints SetWMNormalHints; + PFN_XSetWMProtocols SetWMProtocols; + PFN_XSupportsLocale SupportsLocale; + PFN_XSync Sync; + PFN_XTranslateCoordinates TranslateCoordinates; + PFN_XUndefineCursor UndefineCursor; + PFN_XUngrabPointer UngrabPointer; + PFN_XUnmapWindow UnmapWindow; + PFN_XUnsetICFocus UnsetICFocus; + PFN_XVisualIDFromVisual VisualIDFromVisual; + PFN_XWarpPointer WarpPointer; + PFN_Xutf8LookupString utf8LookupString; + PFN_Xutf8SetWMProperties utf8SetWMProperties; + } xlib; + + struct { + PFN_XrmDestroyDatabase DestroyDatabase; + PFN_XrmGetResource GetResource; + PFN_XrmGetStringDatabase GetStringDatabase; + PFN_XrmInitialize Initialize; + PFN_XrmUniqueQuark UniqueQuark; + } xrm; + struct { GLFWbool available; void* handle; @@ -338,6 +626,15 @@ typedef struct _GLFWlibraryX11 int major; int minor; unsigned int group; + PFN_XkbFreeKeyboard FreeKeyboard; + PFN_XkbFreeNames FreeNames; + PFN_XkbGetMap GetMap; + PFN_XkbGetNames GetNames; + PFN_XkbGetState GetState; + PFN_XkbKeycodeToKeysym KeycodeToKeysym; + PFN_XkbQueryExtension QueryExtension; + PFN_XkbSelectEventDetails SelectEventDetails; + PFN_XkbSetDetectableAutoRepeat SetDetectableAutoRepeat; } xkb; struct { diff --git a/src/x11_window.c b/src/x11_window.c index 89356671..48913d07 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2759,7 +2759,7 @@ void _glfwPlatformPollEvents(void) #endif XPending(_glfw.x11.display); - while (XQLength(_glfw.x11.display)) + while (QLength(_glfw.x11.display)) { XEvent event; XNextEvent(_glfw.x11.display, &event); From 4b8ac11aa31352d4a09fbe1e2e234587bd0d3a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 5 Feb 2020 02:01:47 +0100 Subject: [PATCH 206/942] Fix rendering race in offscreen example --- examples/offscreen.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/offscreen.c b/examples/offscreen.c index eca37c48..16b8f3c9 100644 --- a/examples/offscreen.c +++ b/examples/offscreen.c @@ -148,6 +148,7 @@ int main(void) glUseProgram(program); glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp); glDrawArrays(GL_TRIANGLES, 0, 3); + glFinish(); #if USE_NATIVE_OSMESA glfwGetOSMesaColorBuffer(window, &width, &height, NULL, (void**) &buffer); From 27d19d06ca527fe6f69a94e054c2456073a50c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 6 Feb 2020 15:21:36 +0100 Subject: [PATCH 207/942] WGL: Remove unused constants --- src/wgl_context.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/wgl_context.h b/src/wgl_context.h index df983e91..2cf7e4e5 100644 --- a/src/wgl_context.h +++ b/src/wgl_context.h @@ -104,10 +104,6 @@ typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC); #define wglMakeCurrent _glfw.wgl.MakeCurrent #define wglShareLists _glfw.wgl.ShareLists -#define _GLFW_RECREATION_NOT_NEEDED 0 -#define _GLFW_RECREATION_REQUIRED 1 -#define _GLFW_RECREATION_IMPOSSIBLE 2 - #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryWGL wgl From 4381b86b6ba63598de82c3f05824dc00a2b3ec59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 6 Feb 2020 15:46:37 +0100 Subject: [PATCH 208/942] X11: Fix CJK IME input when locale CTYPE is "C" Fixes #1587. Fixes #1636. --- README.md | 1 + include/GLFW/glfw3.h | 4 ++++ src/x11_init.c | 11 ++++------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c543d25f..f8406acc 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Window position events were not emitted during resizing (#1613) - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM - [X11] Bugfix: Querying a disconnected monitor could segfault (#1602) + - [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636) - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 4f5f3607..cbff44a0 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1831,6 +1831,10 @@ typedef struct GLFWgamepadstate * bundle, if present. This can be disabled with the @ref * GLFW_COCOA_CHDIR_RESOURCES init hint. * + * @remark @x11 This function will set the `LC_CTYPE` category of the + * application locale according to the current environment if that category is + * still "C". This is because the "C" locale breaks Unicode text input. + * * @thread_safety This function must only be called from the main thread. * * @sa @ref intro_init diff --git a/src/x11_init.c b/src/x11_init.c index eb440711..2ce7b4ef 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -936,15 +936,12 @@ Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot) int _glfwPlatformInit(void) { -#if !defined(X_HAVE_UTF8_STRING) - // HACK: If the current locale is "C" and the Xlib UTF-8 functions are - // unavailable, apply the environment's locale in the hope that it's - // both available and not "C" - // This is done because the "C" locale breaks wide character input, - // which is what we fall back on when UTF-8 support is missing + // HACK: If the application has left the locale as "C" then both wide + // character text input and explicit UTF-8 input via XIM will break + // This sets the CTYPE part of the current locale from the environment + // in the hope that it is set to something more sane than "C" if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0) setlocale(LC_CTYPE, ""); -#endif #if defined(__CYGWIN__) _glfw.x11.xlib.handle = _glfw_dlopen("libX11-6.so"); From 6aca3e99f03617df1dd9081f20bd5408baf2a5d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 12 Feb 2020 14:53:18 +0100 Subject: [PATCH 209/942] Wayland: Remove unused link-time dependency The wayland-egl library is now loaded dynamically at init. This narrows the pkgconfig dependencies to the link-time depdendencies. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95753ebc..80dbc13a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,7 +235,7 @@ if (_GLFW_WAYLAND) find_package(WaylandScanner REQUIRED) find_package(WaylandProtocols 1.15 REQUIRED) - list(APPEND glfw_PKG_DEPS "wayland-egl") + list(APPEND glfw_PKG_DEPS "wayland-client") list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}") list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}") From 72366ac9a98ddb3e5b80b91b214e9ec0f0626c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 5 Mar 2020 20:32:19 +0100 Subject: [PATCH 210/942] Cocoa: Finish launching NSApp in glfwInit This moves the remaining bits of NSApplication initialization into _glfwPlatformInit. As a side-effect of this, any command-line program initializing GLFW will get a menu bar, which is not ideal. If this has happened to you and a bisect led you here, please see the GLFW_COCOA_MENUBAR init hint introduced in GLFW 3.3. If this patch is a terrible idea, please get in touch in the 3.4 release timeframe. This is a replacement for 6e6805000ac7ddf39c8c5f6be3e877770cba5083, which attempts to preserve the existing menu bar creation behavior for the 3.3-stable branch. Fixes #1649. --- README.md | 3 +++ docs/context.dox | 4 ---- docs/intro.dox | 11 ++++++++--- docs/news.dox | 7 +++++++ include/GLFW/glfw3.h | 15 ++++++++------- src/cocoa_init.m | 8 ++++---- src/cocoa_platform.h | 1 - src/cocoa_window.m | 15 --------------- tests/monitors.c | 2 ++ 9 files changed, 32 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index f8406acc..f63f3efd 100644 --- a/README.md +++ b/README.md @@ -148,12 +148,15 @@ information on what to include when reporting a bug. (#1623) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle + - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) - [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 + - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread + would abort (#1649) - [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/docs/context.dox b/docs/context.dox index 69b8fa7f..dd952122 100644 --- a/docs/context.dox +++ b/docs/context.dox @@ -84,10 +84,6 @@ objects are recommended for rendering with such contexts. You should still [process events](@ref events) as long as you have at least one window, even if none of them are visible. -@macos The first time a window is created the menu bar is created. This is not -desirable for example when writing a command-line only application. Menu bar -creation can be disabled with the @ref GLFW_COCOA_MENUBAR init hint. - @subsection context_less Windows without contexts diff --git a/docs/intro.dox b/docs/intro.dox index a72b620e..36e33525 100644 --- a/docs/intro.dox +++ b/docs/intro.dox @@ -62,6 +62,11 @@ before the application exits. Modern systems are very good at freeing resources allocated by programs that exit, but GLFW sometimes has to change global system settings and these might not be restored without termination. +@macos When the library is initialized the main menu and dock icon are created. +These are not desirable for a command-line only program. The creation of the +main menu and dock icon can be disabled with the @ref GLFW_COCOA_MENUBAR init +hint. + @subsection init_hints Initialization hints @@ -97,9 +102,9 @@ the application to the `Contents/Resources` subdirectory of the application's bundle, if present. Set this with @ref glfwInitHint. @anchor GLFW_COCOA_MENUBAR_hint -__GLFW_COCOA_MENUBAR__ specifies whether to create a basic menu bar, either from -a nib or manually, when the first window is created, which is when AppKit is -initialized. Set this with @ref glfwInitHint. +__GLFW_COCOA_MENUBAR__ specifies whether to create the menu bar and dock icon +when GLFW is initialized. This applies whether the menu bar is created from +a nib or manually by GLFW. Set this with @ref glfwInitHint. @subsubsection init_hints_values Supported and default values diff --git a/docs/news.dox b/docs/news.dox index 81af3d1d..4dd72795 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -52,6 +52,13 @@ add_subdirectory(path/to/glfw) @endcode +@subsubsection initmenu_34 macOS main menu now created at initialization + +GLFW now creates the main menu and completes the initialization of NSApplication +during initialization. Programs that do not want a main menu can disable it +with the [GLFW_COCOA_MENUBAR](@ref GLFW_COCOA_MENUBAR_hint) init hint. + + @subsubsection corevideo_34 CoreVideo dependency has been removed GLFW no longer depends on the CoreVideo framework on macOS and it no longer diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index cbff44a0..e5b9b6c6 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1831,6 +1831,14 @@ typedef struct GLFWgamepadstate * bundle, if present. This can be disabled with the @ref * GLFW_COCOA_CHDIR_RESOURCES init hint. * + * @remark @macos This function will create the main menu and dock icon for the + * application. If GLFW finds a `MainMenu.nib` it is loaded and assumed to + * contain a menu bar. Otherwise a minimal menu bar is created manually with + * common commands like Hide, Quit and About. The About entry opens a minimal + * about dialog with information from the application's bundle. The menu bar + * and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init + * hint. + * * @remark @x11 This function will set the `LC_CTYPE` category of the * application locale according to the current environment if that category is * still "C". This is because the "C" locale breaks Unicode text input. @@ -2674,13 +2682,6 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) * in the Mac Developer Library. * - * @remark @macos The first time a window is created the menu bar is created. - * If GLFW finds a `MainMenu.nib` it is loaded and assumed to contain a menu - * bar. Otherwise a minimal menu bar is created manually with common commands - * like Hide, Quit and About. The About entry opens a minimal about dialog - * with information from the application's bundle. Menu bar creation can be - * disabled entirely with the @ref GLFW_COCOA_MENUBAR init hint. - * * @remark @macos On OS X 10.10 and later the window frame will not be rendered * at full resolution on Retina displays unless the * [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index cbc9462f..434e5beb 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -447,7 +447,6 @@ static GLFWbool initializeTIS(void) - (void)applicationDidFinishLaunching:(NSNotification *)notification { - _glfw.ns.finishedLaunching = GLFW_TRUE; _glfwPlatformPostEmptyEvent(); [NSApp stop:nil]; } @@ -503,9 +502,6 @@ int _glfwPlatformInit(void) toTarget:_glfw.ns.helper withObject:nil]; - if (NSApp) - _glfw.ns.finishedLaunching = GLFW_TRUE; - [NSApplication sharedApplication]; _glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init]; @@ -558,6 +554,10 @@ int _glfwPlatformInit(void) _glfwInitJoysticksNS(); _glfwPollMonitorsNS(); + + if (![[NSRunningApplication currentApplication] isFinishedLaunching]) + [NSApp run]; + return GLFW_TRUE; } // autoreleasepool diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 9a979af2..90714341 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -141,7 +141,6 @@ typedef struct _GLFWlibraryNS { CGEventSourceRef eventSource; id delegate; - GLFWbool finishedLaunching; GLFWbool cursorHidden; TISInputSourceRef inputSource; IOHIDManagerRef hidManager; diff --git a/src/cocoa_window.m b/src/cocoa_window.m index e12b5cda..c50bf21a 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -884,9 +884,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, { @autoreleasepool { - if (!_glfw.ns.finishedLaunching) - [NSApp run]; - if (!createNativeWindow(window, wndconfig, fbconfig)) return GLFW_FALSE; @@ -1377,9 +1374,6 @@ void _glfwPlatformPollEvents(void) { @autoreleasepool { - if (!_glfw.ns.finishedLaunching) - [NSApp run]; - for (;;) { NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny @@ -1399,9 +1393,6 @@ 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. @@ -1420,9 +1411,6 @@ void _glfwPlatformWaitEventsTimeout(double timeout) { @autoreleasepool { - if (!_glfw.ns.finishedLaunching) - [NSApp run]; - NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout]; NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:date @@ -1440,9 +1428,6 @@ void _glfwPlatformPostEmptyEvent(void) { @autoreleasepool { - if (!_glfw.ns.finishedLaunching) - [NSApp run]; - NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined location:NSMakePoint(0, 0) modifierFlags:0 diff --git a/tests/monitors.c b/tests/monitors.c index 2b75d7b1..c66950bf 100644 --- a/tests/monitors.c +++ b/tests/monitors.c @@ -241,6 +241,8 @@ int main(int argc, char** argv) glfwSetErrorCallback(error_callback); + glfwInitHint(GLFW_COCOA_MENUBAR, GLFW_FALSE); + if (!glfwInit()) exit(EXIT_FAILURE); From 9516df52a4745a67f4e1d58d3de32c74b8c33ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 12 Mar 2020 01:57:10 +0100 Subject: [PATCH 211/942] Fix unclear language in build guide Fixes #1658. --- docs/build.dox | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/build.dox b/docs/build.dox index b22e5f0c..03d0fd7d 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -209,7 +209,7 @@ find_package(OpenGL REQUIRED) @endcode If OpenGL is found, the `OpenGL::GL` target is added to your project, containing -library and include directory paths. Link against this like above. +library and include directory paths. Link against this like any other library. @code{.cmake} target_link_libraries(myapp OpenGL::GL) @@ -248,7 +248,7 @@ find_package(OpenGL REQUIRED) @endcode If OpenGL is found, the `OpenGL::GL` target is added to your project, containing -library and include directory paths. Link against this like above. +library and include directory paths. Link against this like any other library. @code{.cmake} target_link_libraries(myapp OpenGL::GL) From 350ba73267271d71984ad69af1e006f35ded1078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 2 Mar 2020 19:43:21 +0100 Subject: [PATCH 212/942] Update linmath.h This updates our linmath.h to the latest version plus minor local fixes for MSVC and Clang. Fixes #1653. --- deps/linmath.h | 217 ++++++++++++++++++++++++++++++------------------- 1 file changed, 132 insertions(+), 85 deletions(-) diff --git a/deps/linmath.h b/deps/linmath.h index 9c2e2a0a..c4c0e24e 100644 --- a/deps/linmath.h +++ b/deps/linmath.h @@ -3,31 +3,40 @@ #include -#ifdef _MSC_VER -#define inline __inline +/* 2020-03-02 Camilla Löwy + * - Added inclusion of string.h for memcpy + * - Replaced tan and acos with tanf and acosf + * - Replaced double constants with float equivalents + */ +#include + +#ifdef LINMATH_NO_INLINE +#define LINMATH_H_FUNC static +#else +#define LINMATH_H_FUNC static inline #endif #define LINMATH_H_DEFINE_VEC(n) \ typedef float vec##n[n]; \ -static inline void vec##n##_add(vec##n r, vec##n const a, vec##n const b) \ +LINMATH_H_FUNC void vec##n##_add(vec##n r, vec##n const a, vec##n const b) \ { \ int i; \ for(i=0; ib[i] ? a[i] : b[i]; \ } LINMATH_H_DEFINE_VEC(2) LINMATH_H_DEFINE_VEC(3) LINMATH_H_DEFINE_VEC(4) -static inline void vec3_mul_cross(vec3 r, vec3 const a, vec3 const b) +LINMATH_H_FUNC void vec3_mul_cross(vec3 r, vec3 const a, vec3 const b) { r[0] = a[1]*b[2] - a[2]*b[1]; r[1] = a[2]*b[0] - a[0]*b[2]; r[2] = a[0]*b[1] - a[1]*b[0]; } -static inline void vec3_reflect(vec3 r, vec3 const v, vec3 const n) +LINMATH_H_FUNC void vec3_reflect(vec3 r, vec3 const v, vec3 const n) { float p = 2.f*vec3_mul_inner(v, n); int i; @@ -64,7 +85,7 @@ static inline void vec3_reflect(vec3 r, vec3 const v, vec3 const n) r[i] = v[i] - p*n[i]; } -static inline void vec4_mul_cross(vec4 r, vec4 a, vec4 b) +LINMATH_H_FUNC void vec4_mul_cross(vec4 r, vec4 a, vec4 b) { r[0] = a[1]*b[2] - a[2]*b[1]; r[1] = a[2]*b[0] - a[0]*b[2]; @@ -72,7 +93,7 @@ static inline void vec4_mul_cross(vec4 r, vec4 a, vec4 b) r[3] = 1.f; } -static inline void vec4_reflect(vec4 r, vec4 v, vec4 n) +LINMATH_H_FUNC void vec4_reflect(vec4 r, vec4 v, vec4 n) { float p = 2.f*vec4_mul_inner(v, n); int i; @@ -81,58 +102,58 @@ static inline void vec4_reflect(vec4 r, vec4 v, vec4 n) } typedef vec4 mat4x4[4]; -static inline void mat4x4_identity(mat4x4 M) +LINMATH_H_FUNC void mat4x4_identity(mat4x4 M) { int i, j; for(i=0; i<4; ++i) for(j=0; j<4; ++j) M[i][j] = i==j ? 1.f : 0.f; } -static inline void mat4x4_dup(mat4x4 M, mat4x4 N) +LINMATH_H_FUNC void mat4x4_dup(mat4x4 M, mat4x4 N) { int i, j; for(i=0; i<4; ++i) for(j=0; j<4; ++j) M[i][j] = N[i][j]; } -static inline void mat4x4_row(vec4 r, mat4x4 M, int i) +LINMATH_H_FUNC void mat4x4_row(vec4 r, mat4x4 M, int i) { int k; for(k=0; k<4; ++k) r[k] = M[k][i]; } -static inline void mat4x4_col(vec4 r, mat4x4 M, int i) +LINMATH_H_FUNC void mat4x4_col(vec4 r, mat4x4 M, int i) { int k; for(k=0; k<4; ++k) r[k] = M[i][k]; } -static inline void mat4x4_transpose(mat4x4 M, mat4x4 N) +LINMATH_H_FUNC void mat4x4_transpose(mat4x4 M, mat4x4 N) { int i, j; for(j=0; j<4; ++j) for(i=0; i<4; ++i) M[i][j] = N[j][i]; } -static inline void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b) +LINMATH_H_FUNC void mat4x4_add(mat4x4 M, mat4x4 a, mat4x4 b) { int i; for(i=0; i<4; ++i) vec4_add(M[i], a[i], b[i]); } -static inline void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b) +LINMATH_H_FUNC void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b) { int i; for(i=0; i<4; ++i) vec4_sub(M[i], a[i], b[i]); } -static inline void mat4x4_scale(mat4x4 M, mat4x4 a, float k) +LINMATH_H_FUNC void mat4x4_scale(mat4x4 M, mat4x4 a, float k) { int i; for(i=0; i<4; ++i) vec4_scale(M[i], a[i], k); } -static inline void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z) +LINMATH_H_FUNC void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, float z) { int i; vec4_scale(M[0], a[0], x); @@ -142,7 +163,7 @@ static inline void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, floa M[3][i] = a[3][i]; } } -static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) +LINMATH_H_FUNC void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) { mat4x4 temp; int k, r, c; @@ -153,7 +174,7 @@ static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) } mat4x4_dup(M, temp); } -static inline void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v) +LINMATH_H_FUNC void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v) { int i, j; for(j=0; j<4; ++j) { @@ -162,14 +183,14 @@ static inline void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v) r[j] += M[i][j] * v[i]; } } -static inline void mat4x4_translate(mat4x4 T, float x, float y, float z) +LINMATH_H_FUNC void mat4x4_translate(mat4x4 T, float x, float y, float z) { mat4x4_identity(T); T[3][0] = x; T[3][1] = y; T[3][2] = z; } -static inline void mat4x4_translate_in_place(mat4x4 M, float x, float y, float z) +LINMATH_H_FUNC void mat4x4_translate_in_place(mat4x4 M, float x, float y, float z) { vec4 t = {x, y, z, 0}; vec4 r; @@ -179,33 +200,32 @@ static inline void mat4x4_translate_in_place(mat4x4 M, float x, float y, float z M[3][i] += vec4_mul_inner(r, t); } } -static inline void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b) +LINMATH_H_FUNC void mat4x4_from_vec3_mul_outer(mat4x4 M, vec3 a, vec3 b) { int i, j; for(i=0; i<4; ++i) for(j=0; j<4; ++j) M[i][j] = i<3 && j<3 ? a[i] * b[j] : 0.f; } -static inline void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, float angle) +LINMATH_H_FUNC void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, float angle) { float s = sinf(angle); float c = cosf(angle); vec3 u = {x, y, z}; if(vec3_len(u) > 1e-4) { - mat4x4 T, C, S = {{0}}; - vec3_norm(u, u); + mat4x4 T; mat4x4_from_vec3_mul_outer(T, u, u); - S[1][2] = u[0]; - S[2][1] = -u[0]; - S[2][0] = u[1]; - S[0][2] = -u[1]; - S[0][1] = u[2]; - S[1][0] = -u[2]; - + mat4x4 S = { + { 0, u[2], -u[1], 0}, + {-u[2], 0, u[0], 0}, + { u[1], -u[0], 0, 0}, + { 0, 0, 0, 0} + }; mat4x4_scale(S, S, s); + mat4x4 C; mat4x4_identity(C); mat4x4_sub(C, C, T); @@ -214,13 +234,13 @@ static inline void mat4x4_rotate(mat4x4 R, mat4x4 M, float x, float y, float z, mat4x4_add(T, T, C); mat4x4_add(T, T, S); - T[3][3] = 1.; + T[3][3] = 1.; mat4x4_mul(R, M, T); } else { mat4x4_dup(R, M); } } -static inline void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle) +LINMATH_H_FUNC void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle) { float s = sinf(angle); float c = cosf(angle); @@ -232,7 +252,7 @@ static inline void mat4x4_rotate_X(mat4x4 Q, mat4x4 M, float angle) }; mat4x4_mul(Q, M, R); } -static inline void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle) +LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle) { float s = sinf(angle); float c = cosf(angle); @@ -244,7 +264,7 @@ static inline void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle) }; mat4x4_mul(Q, M, R); } -static inline void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle) +LINMATH_H_FUNC void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle) { float s = sinf(angle); float c = cosf(angle); @@ -256,9 +276,8 @@ static inline void mat4x4_rotate_Z(mat4x4 Q, mat4x4 M, float angle) }; mat4x4_mul(Q, M, R); } -static inline void mat4x4_invert(mat4x4 T, mat4x4 M) +LINMATH_H_FUNC void mat4x4_invert(mat4x4 T, mat4x4 M) { - float idet; float s[6]; float c[6]; s[0] = M[0][0]*M[1][1] - M[1][0]*M[0][1]; @@ -274,10 +293,10 @@ static inline void mat4x4_invert(mat4x4 T, mat4x4 M) c[3] = M[2][1]*M[3][2] - M[3][1]*M[2][2]; c[4] = M[2][1]*M[3][3] - M[3][1]*M[2][3]; c[5] = M[2][2]*M[3][3] - M[3][2]*M[2][3]; - + /* Assumes it is invertible */ - idet = 1.0f/( s[0]*c[5]-s[1]*c[4]+s[2]*c[3]+s[3]*c[2]-s[4]*c[1]+s[5]*c[0] ); - + float idet = 1.0f/( s[0]*c[5]-s[1]*c[4]+s[2]*c[3]+s[3]*c[2]-s[4]*c[1]+s[5]*c[0] ); + T[0][0] = ( M[1][1] * c[5] - M[1][2] * c[4] + M[1][3] * c[3]) * idet; T[0][1] = (-M[0][1] * c[5] + M[0][2] * c[4] - M[0][3] * c[3]) * idet; T[0][2] = ( M[3][1] * s[5] - M[3][2] * s[4] + M[3][3] * s[3]) * idet; @@ -298,35 +317,34 @@ static inline void mat4x4_invert(mat4x4 T, mat4x4 M) T[3][2] = (-M[3][0] * s[3] + M[3][1] * s[1] - M[3][2] * s[0]) * idet; T[3][3] = ( M[2][0] * s[3] - M[2][1] * s[1] + M[2][2] * s[0]) * idet; } -static inline void mat4x4_orthonormalize(mat4x4 R, mat4x4 M) +LINMATH_H_FUNC void mat4x4_orthonormalize(mat4x4 R, mat4x4 M) { + mat4x4_dup(R, M); float s = 1.; vec3 h; - mat4x4_dup(R, M); vec3_norm(R[2], R[2]); - - s = vec3_mul_inner(R[1], R[2]); - vec3_scale(h, R[2], s); - vec3_sub(R[1], R[1], h); - vec3_norm(R[2], R[2]); - + s = vec3_mul_inner(R[1], R[2]); vec3_scale(h, R[2], s); vec3_sub(R[1], R[1], h); vec3_norm(R[1], R[1]); + s = vec3_mul_inner(R[0], R[2]); + vec3_scale(h, R[2], s); + vec3_sub(R[0], R[0], h); + s = vec3_mul_inner(R[0], R[1]); vec3_scale(h, R[1], s); vec3_sub(R[0], R[0], h); vec3_norm(R[0], R[0]); } -static inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t, float n, float f) +LINMATH_H_FUNC void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t, float n, float f) { M[0][0] = 2.f*n/(r-l); M[0][1] = M[0][2] = M[0][3] = 0.f; - + M[1][1] = 2.f*n/(t-b); M[1][0] = M[1][2] = M[1][3] = 0.f; @@ -334,11 +352,11 @@ static inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t, M[2][1] = (t+b)/(t-b); M[2][2] = -(f+n)/(f-n); M[2][3] = -1.f; - + M[3][2] = -2.f*(f*n)/(f-n); M[3][0] = M[3][1] = M[3][3] = 0.f; } -static inline void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, float n, float f) +LINMATH_H_FUNC void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, float n, float f) { M[0][0] = 2.f/(r-l); M[0][1] = M[0][2] = M[0][3] = 0.f; @@ -348,17 +366,17 @@ static inline void mat4x4_ortho(mat4x4 M, float l, float r, float b, float t, fl M[2][2] = -2.f/(f-n); M[2][0] = M[2][1] = M[2][3] = 0.f; - + M[3][0] = -(r+l)/(r-l); M[3][1] = -(t+b)/(t-b); M[3][2] = -(f+n)/(f-n); M[3][3] = 1.f; } -static inline void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, float n, float f) +LINMATH_H_FUNC void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, float n, float f) { /* NOTE: Degrees are an unhandy unit to work with. * linmath.h uses radians for everything! */ - float const a = 1.f / (float) tan(y_fov / 2.f); + float const a = 1.f / tanf(y_fov / 2.f); m[0][0] = a / aspect; m[0][1] = 0.f; @@ -380,7 +398,7 @@ static inline void mat4x4_perspective(mat4x4 m, float y_fov, float aspect, float m[3][2] = -((2.f * f * n) / (f - n)); m[3][3] = 0.f; } -static inline void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up) +LINMATH_H_FUNC void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up) { /* Adapted from Android's OpenGL Matrix.java. */ /* See the OpenGL GLUT documentation for gluLookAt for a description */ @@ -389,15 +407,14 @@ static inline void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up) /* TODO: The negation of of can be spared by swapping the order of * operands in the following cross products in the right way. */ vec3 f; + vec3_sub(f, center, eye); + vec3_norm(f, f); + vec3 s; - vec3 t; - - vec3_sub(f, center, eye); - vec3_norm(f, f); - vec3_mul_cross(s, f, up); vec3_norm(s, s); + vec3 t; vec3_mul_cross(t, s, f); m[0][0] = s[0]; @@ -424,24 +441,24 @@ static inline void mat4x4_look_at(mat4x4 m, vec3 eye, vec3 center, vec3 up) } typedef float quat[4]; -static inline void quat_identity(quat q) +LINMATH_H_FUNC void quat_identity(quat q) { q[0] = q[1] = q[2] = 0.f; q[3] = 1.f; } -static inline void quat_add(quat r, quat a, quat b) +LINMATH_H_FUNC void quat_add(quat r, quat a, quat b) { int i; for(i=0; i<4; ++i) r[i] = a[i] + b[i]; } -static inline void quat_sub(quat r, quat a, quat b) +LINMATH_H_FUNC void quat_sub(quat r, quat a, quat b) { int i; for(i=0; i<4; ++i) r[i] = a[i] - b[i]; } -static inline void quat_mul(quat r, quat p, quat q) +LINMATH_H_FUNC void quat_mul(quat r, quat p, quat q) { vec3 w; vec3_mul_cross(r, p, q); @@ -451,13 +468,13 @@ static inline void quat_mul(quat r, quat p, quat q) vec3_add(r, r, w); r[3] = p[3]*q[3] - vec3_mul_inner(p, q); } -static inline void quat_scale(quat r, quat v, float s) +LINMATH_H_FUNC void quat_scale(quat r, quat v, float s) { int i; for(i=0; i<4; ++i) r[i] = v[i] * s; } -static inline float quat_inner_product(quat a, quat b) +LINMATH_H_FUNC float quat_inner_product(quat a, quat b) { float p = 0.f; int i; @@ -465,42 +482,43 @@ static inline float quat_inner_product(quat a, quat b) p += b[i]*a[i]; return p; } -static inline void quat_conj(quat r, quat q) +LINMATH_H_FUNC void quat_conj(quat r, quat q) { int i; for(i=0; i<3; ++i) r[i] = -q[i]; r[3] = q[3]; } -static inline void quat_rotate(quat r, float angle, vec3 axis) { - int i; +LINMATH_H_FUNC void quat_rotate(quat r, float angle, vec3 axis) { vec3 v; vec3_scale(v, axis, sinf(angle / 2)); + int i; for(i=0; i<3; ++i) r[i] = v[i]; r[3] = cosf(angle / 2); } #define quat_norm vec4_norm -static inline void quat_mul_vec3(vec3 r, quat q, vec3 v) +LINMATH_H_FUNC void quat_mul_vec3(vec3 r, quat q, vec3 v) { /* * Method by Fabian 'ryg' Giessen (of Farbrausch) t = 2 * cross(q.xyz, v) v' = v + q.w * t + cross(q.xyz, t) */ - vec3 t = {q[0], q[1], q[2]}; + vec3 t; + vec3 q_xyz = {q[0], q[1], q[2]}; vec3 u = {q[0], q[1], q[2]}; - vec3_mul_cross(t, t, v); + vec3_mul_cross(t, q_xyz, v); vec3_scale(t, t, 2); - vec3_mul_cross(u, u, t); + vec3_mul_cross(u, q_xyz, t); vec3_scale(t, t, q[3]); vec3_add(r, v, t); vec3_add(r, r, u); } -static inline void mat4x4_from_quat(mat4x4 M, quat q) +LINMATH_H_FUNC void mat4x4_from_quat(mat4x4 M, quat q) { float a = q[3]; float b = q[0]; @@ -510,7 +528,7 @@ static inline void mat4x4_from_quat(mat4x4 M, quat q) float b2 = b*b; float c2 = c*c; float d2 = d*d; - + M[0][0] = a2 + b2 - c2 - d2; M[0][1] = 2.f*(b*c + a*d); M[0][2] = 2.f*(b*d - a*c); @@ -530,7 +548,7 @@ static inline void mat4x4_from_quat(mat4x4 M, quat q) M[3][3] = 1.f; } -static inline void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q) +LINMATH_H_FUNC void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q) { /* XXX: The way this is written only works for othogonal matrices. */ /* TODO: Take care of non-orthogonal case. */ @@ -541,7 +559,7 @@ static inline void mat4x4o_mul_quat(mat4x4 R, mat4x4 M, quat q) R[3][0] = R[3][1] = R[3][2] = 0.f; R[3][3] = 1.f; } -static inline void quat_from_mat4x4(quat q, mat4x4 M) +LINMATH_H_FUNC void quat_from_mat4x4(quat q, mat4x4 M) { float r=0.f; int i; @@ -557,7 +575,7 @@ static inline void quat_from_mat4x4(quat q, mat4x4 M) p = &perm[i]; } - r = (float) sqrt(1.f + M[p[0]][p[0]] - M[p[1]][p[1]] - M[p[2]][p[2]] ); + r = sqrtf(1.f + M[p[0]][p[0]] - M[p[1]][p[1]] - M[p[2]][p[2]] ); if(r < 1e-6) { q[0] = 1.f; @@ -571,4 +589,33 @@ static inline void quat_from_mat4x4(quat q, mat4x4 M) q[3] = (M[p[2]][p[1]] - M[p[1]][p[2]])/(2.f*r); } +LINMATH_H_FUNC void mat4x4_arcball(mat4x4 R, mat4x4 M, vec2 _a, vec2 _b, float s) +{ + vec2 a; memcpy(a, _a, sizeof(a)); + vec2 b; memcpy(b, _b, sizeof(b)); + + float z_a = 0.; + float z_b = 0.; + + if(vec2_len(a) < 1.f) { + z_a = sqrtf(1.f - vec2_mul_inner(a, a)); + } else { + vec2_norm(a, a); + } + + if(vec2_len(b) < 1.f) { + z_b = sqrtf(1.f - vec2_mul_inner(b, b)); + } else { + vec2_norm(b, b); + } + + vec3 a_ = {a[0], a[1], z_a}; + vec3 b_ = {b[0], b[1], z_b}; + + vec3 c_; + vec3_mul_cross(c_, a_, b_); + + float const angle = acosf(vec3_mul_inner(a_, b_)) * s; + mat4x4_rotate(R, M, c_[0], c_[1], c_[2], angle); +} #endif From 44b5d06583cd21ac237eb8f6263db03faf1726c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 22 Jan 2020 20:12:36 +0100 Subject: [PATCH 213/942] X11: Add support for XIM callbacks This adds support for the XIM instantiate and destroy callbacks, letting GLFW detect both when the current input method disappears and when a new one is started. Tested with ibus. --- README.md | 2 ++ src/x11_init.c | 59 +++++++++++++++++++++++++++++++++++------- src/x11_platform.h | 10 ++++++++ src/x11_window.c | 64 +++++++++++++++++++++++++++++++--------------- 4 files changed, 105 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index f63f3efd..3977f0ff 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,8 @@ information on what to include when reporting a bug. - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM - [X11] Bugfix: Querying a disconnected monitor could segfault (#1602) - [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636) + - [X11] Bugfix: Termination would segfault if the IM had been destroyed + - [X11] Bugfix: Any IM started after initialization would not be detected - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/x11_init.c b/src/x11_init.c index 2ce7b4ef..d640a8fe 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -349,6 +349,40 @@ static GLFWbool hasUsableInputMethodStyle(void) return found; } +static void inputMethodDestroyCallback(XIM im, XPointer clientData, XPointer callData) +{ + _glfw.x11.im = NULL; +} + +static void inputMethodInstantiateCallback(Display* display, + XPointer clientData, + XPointer callData) +{ + if (_glfw.x11.im) + return; + + _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL); + if (_glfw.x11.im) + { + if (!hasUsableInputMethodStyle()) + { + XCloseIM(_glfw.x11.im); + _glfw.x11.im = NULL; + } + } + + if (_glfw.x11.im) + { + XIMCallback callback; + callback.callback = (XIMProc) inputMethodDestroyCallback; + callback.client_data = NULL; + XSetIMValues(_glfw.x11.im, XNDestroyCallback, &callback, NULL); + + for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) + _glfwCreateInputContextX11(window); + } +} + // Check whether the specified atom is supported // static Atom getSupportedAtom(Atom* supportedAtoms, @@ -1066,6 +1100,8 @@ int _glfwPlatformInit(void) _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryPointer"); _glfw.x11.xlib.RaiseWindow = (PFN_XRaiseWindow) _glfw_dlsym(_glfw.x11.xlib.handle, "XRaiseWindow"); + _glfw.x11.xlib.RegisterIMInstantiateCallback = (PFN_XRegisterIMInstantiateCallback) + _glfw_dlsym(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback"); _glfw.x11.xlib.ResizeWindow = (PFN_XResizeWindow) _glfw_dlsym(_glfw.x11.xlib.handle, "XResizeWindow"); _glfw.x11.xlib.ResourceManagerString = (PFN_XResourceManagerString) @@ -1082,6 +1118,8 @@ int _glfwPlatformInit(void) _glfw_dlsym(_glfw.x11.xlib.handle, "XSetErrorHandler"); _glfw.x11.xlib.SetICFocus = (PFN_XSetICFocus) _glfw_dlsym(_glfw.x11.xlib.handle, "XSetICFocus"); + _glfw.x11.xlib.SetIMValues = (PFN_XSetIMValues) + _glfw_dlsym(_glfw.x11.xlib.handle, "XSetIMValues"); _glfw.x11.xlib.SetInputFocus = (PFN_XSetInputFocus) _glfw_dlsym(_glfw.x11.xlib.handle, "XSetInputFocus"); _glfw.x11.xlib.SetLocaleModifiers = (PFN_XSetLocaleModifiers) @@ -1142,6 +1180,8 @@ int _glfwPlatformInit(void) _glfw_dlsym(_glfw.x11.xlib.handle, "XrmInitialize"); _glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark) _glfw_dlsym(_glfw.x11.xlib.handle, "XrmUniqueQuark"); + _glfw.x11.xlib.UnregisterIMInstantiateCallback = (PFN_XUnregisterIMInstantiateCallback) + _glfw_dlsym(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback"); _glfw.x11.xlib.utf8LookupString = (PFN_Xutf8LookupString) _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8LookupString"); _glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties) @@ -1184,15 +1224,11 @@ int _glfwPlatformInit(void) { XSetLocaleModifiers(""); - _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL); - if (_glfw.x11.im) - { - if (!hasUsableInputMethodStyle()) - { - XCloseIM(_glfw.x11.im); - _glfw.x11.im = NULL; - } - } + // If an IM is already present our callback will be called right away + XRegisterIMInstantiateCallback(_glfw.x11.display, + NULL, NULL, NULL, + inputMethodInstantiateCallback, + NULL); } #if defined(__linux__) @@ -1229,6 +1265,11 @@ void _glfwPlatformTerminate(void) free(_glfw.x11.primarySelectionString); free(_glfw.x11.clipboardString); + XUnregisterIMInstantiateCallback(_glfw.x11.display, + NULL, NULL, NULL, + inputMethodInstantiateCallback, + NULL); + if (_glfw.x11.im) { XCloseIM(_glfw.x11.im); diff --git a/src/x11_platform.h b/src/x11_platform.h index d6b345dd..43a0ce19 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -104,6 +104,7 @@ typedef int (* PFN_XPending)(Display*); typedef Bool (* PFN_XQueryExtension)(Display*,const char*,int*,int*,int*); typedef Bool (* PFN_XQueryPointer)(Display*,Window,Window*,Window*,int*,int*,int*,int*,unsigned int*); typedef int (* PFN_XRaiseWindow)(Display*,Window); +typedef Bool (* PFN_XRegisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer); typedef int (* PFN_XResizeWindow)(Display*,Window,unsigned int,unsigned int); typedef char* (* PFN_XResourceManagerString)(Display*); typedef int (* PFN_XSaveContext)(Display*,XID,XContext,const char*); @@ -112,6 +113,7 @@ typedef Status (* PFN_XSendEvent)(Display*,Window,Bool,long,XEvent*); typedef int (* PFN_XSetClassHint)(Display*,Window,XClassHint*); typedef XErrorHandler (* PFN_XSetErrorHandler)(XErrorHandler); typedef void (* PFN_XSetICFocus)(XIC); +typedef char* (* PFN_XSetIMValues)(XIM,...); typedef int (* PFN_XSetInputFocus)(Display*,Window,int,Time); typedef char* (* PFN_XSetLocaleModifiers)(const char*); typedef int (* PFN_XSetScreenSaver)(Display*,int,int,int,int); @@ -142,6 +144,7 @@ typedef Bool (* PFN_XrmGetResource)(XrmDatabase,const char*,const char*,char**,X typedef XrmDatabase (* PFN_XrmGetStringDatabase)(const char*); typedef void (* PFN_XrmInitialize)(void); typedef XrmQuark (* PFN_XrmUniqueQuark)(void); +typedef Bool (* PFN_XUnregisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer); typedef int (* PFN_Xutf8LookupString)(XIC,XKeyPressedEvent*,char*,int,KeySym*,Status*); typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char*,char**,int,XSizeHints*,XWMHints*,XClassHint*); #define XAllocClassHint _glfw.x11.xlib.AllocClassHint @@ -200,6 +203,7 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char #define XQueryExtension _glfw.x11.xlib.QueryExtension #define XQueryPointer _glfw.x11.xlib.QueryPointer #define XRaiseWindow _glfw.x11.xlib.RaiseWindow +#define XRegisterIMInstantiateCallback _glfw.x11.xlib.RegisterIMInstantiateCallback #define XResizeWindow _glfw.x11.xlib.ResizeWindow #define XResourceManagerString _glfw.x11.xlib.ResourceManagerString #define XSaveContext _glfw.x11.xlib.SaveContext @@ -208,6 +212,7 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char #define XSetClassHint _glfw.x11.xlib.SetClassHint #define XSetErrorHandler _glfw.x11.xlib.SetErrorHandler #define XSetICFocus _glfw.x11.xlib.SetICFocus +#define XSetIMValues _glfw.x11.xlib.SetIMValues #define XSetInputFocus _glfw.x11.xlib.SetInputFocus #define XSetLocaleModifiers _glfw.x11.xlib.SetLocaleModifiers #define XSetScreenSaver _glfw.x11.xlib.SetScreenSaver @@ -238,6 +243,7 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char #define XrmGetStringDatabase _glfw.x11.xrm.GetStringDatabase #define XrmInitialize _glfw.x11.xrm.Initialize #define XrmUniqueQuark _glfw.x11.xrm.UniqueQuark +#define XUnregisterIMInstantiateCallback _glfw.x11.xlib.UnregisterIMInstantiateCallback #define Xutf8LookupString _glfw.x11.xlib.utf8LookupString #define Xutf8SetWMProperties _glfw.x11.xlib.utf8SetWMProperties @@ -553,6 +559,7 @@ typedef struct _GLFWlibraryX11 PFN_XQueryExtension QueryExtension; PFN_XQueryPointer QueryPointer; PFN_XRaiseWindow RaiseWindow; + PFN_XRegisterIMInstantiateCallback RegisterIMInstantiateCallback; PFN_XResizeWindow ResizeWindow; PFN_XResourceManagerString ResourceManagerString; PFN_XSaveContext SaveContext; @@ -561,6 +568,7 @@ typedef struct _GLFWlibraryX11 PFN_XSetClassHint SetClassHint; PFN_XSetErrorHandler SetErrorHandler; PFN_XSetICFocus SetICFocus; + PFN_XSetIMValues SetIMValues; PFN_XSetInputFocus SetInputFocus; PFN_XSetLocaleModifiers SetLocaleModifiers; PFN_XSetScreenSaver SetScreenSaver; @@ -577,6 +585,7 @@ typedef struct _GLFWlibraryX11 PFN_XUnsetICFocus UnsetICFocus; PFN_XVisualIDFromVisual VisualIDFromVisual; PFN_XWarpPointer WarpPointer; + PFN_XUnregisterIMInstantiateCallback UnregisterIMInstantiateCallback; PFN_Xutf8LookupString utf8LookupString; PFN_Xutf8SetWMProperties utf8SetWMProperties; } xlib; @@ -753,4 +762,5 @@ void _glfwReleaseErrorHandlerX11(void); void _glfwInputErrorX11(int error, const char* message); void _glfwPushSelectionToManagerX11(void); +void _glfwCreateInputContextX11(_GLFWwindow* window); diff --git a/src/x11_window.c b/src/x11_window.c index 48913d07..7eda5b8b 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -590,6 +590,14 @@ static void enableCursor(_GLFWwindow* window) updateCursorImage(window); } +// Clear its handle when the input context has been destroyed +// +static void inputContextDestroyCallback(XIC ic, XPointer clientData, XPointer callData) +{ + _GLFWwindow* window = (_GLFWwindow*) clientData; + window->x11.ic = NULL; +} + // Create the X11 window (and its colormap) // static GLFWbool createNativeWindow(_GLFWwindow* window, @@ -768,27 +776,10 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, PropModeReplace, (unsigned char*) &version, 1); } - _glfwPlatformSetWindowTitle(window, wndconfig->title); - if (_glfw.x11.im) - { - window->x11.ic = XCreateIC(_glfw.x11.im, - XNInputStyle, - XIMPreeditNothing | XIMStatusNothing, - XNClientWindow, - window->x11.handle, - XNFocusWindow, - window->x11.handle, - 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); - } + _glfwCreateInputContextX11(window); + _glfwPlatformSetWindowTitle(window, wndconfig->title); _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos); _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height); @@ -1173,8 +1164,7 @@ static void processEvent(XEvent *event) if (event->type == KeyPress || event->type == KeyRelease) keycode = event->xkey.keycode; - if (_glfw.x11.im) - filtered = XFilterEvent(event, None); + filtered = XFilterEvent(event, None); if (_glfw.x11.randr.available) { @@ -1961,6 +1951,38 @@ void _glfwPushSelectionToManagerX11(void) } } +void _glfwCreateInputContextX11(_GLFWwindow* window) +{ + XIMCallback callback; + callback.callback = (XIMProc) inputContextDestroyCallback; + callback.client_data = (XPointer) window; + + window->x11.ic = XCreateIC(_glfw.x11.im, + XNInputStyle, + XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, + window->x11.handle, + XNFocusWindow, + window->x11.handle, + XNDestroyCallback, + &callback, + NULL); + + if (window->x11.ic) + { + XWindowAttributes attribs; + XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs); + + unsigned long filter = 0; + if (XGetICValues(window->x11.ic, XNFilterEvents, &filter, NULL) == NULL) + { + XSelectInput(_glfw.x11.display, + window->x11.handle, + attribs.your_event_mask | filter); + } + } +} + ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// From 2c8e0512ddb1e8baa73c5b8a03a79aedb4e5939d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Mar 2020 17:13:59 +0100 Subject: [PATCH 214/942] X11: Filter out Xlib errors from other connections --- README.md | 2 ++ src/x11_init.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 3977f0ff..c6b19b76 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,8 @@ information on what to include when reporting a bug. - [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636) - [X11] Bugfix: Termination would segfault if the IM had been destroyed - [X11] Bugfix: Any IM started after initialization would not be detected + - [X11] Bugfix: Xlib errors caused by other parts of the application could be + reported as GLFW errors - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/x11_init.c b/src/x11_init.c index d640a8fe..c6ba3a19 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -890,6 +890,9 @@ static Window createHelperWindow(void) // static int errorHandler(Display *display, XErrorEvent* event) { + if (_glfw.x11.display != display) + return 0; + _glfw.x11.errorCode = event->error_code; return 0; } From e65de2941c056ee5833b4dab3db36b297b53aa14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 19 Mar 2020 23:28:21 +0100 Subject: [PATCH 215/942] X11: Improve window handle race condition The non-root parent window owned by the WM could be destroyed before we process the ConfigureNotify event using the cached parent handle. Bug was found by unmapping a decorated window. This like all uses of the Xlib error handler is not thread safe and there is nothing we can do about that short of moving to XCB. Fixes #1633. --- README.md | 1 + src/x11_window.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index c6b19b76..3fc111ff 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Any IM started after initialization would not be detected - [X11] Bugfix: Xlib errors caused by other parts of the application could be reported as GLFW errors + - [X11] Bugfix: A handle race condition could cause a `BadWindow` error (#1633) - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/x11_window.c b/src/x11_window.c index 7eda5b8b..d6e6bf37 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1547,6 +1547,8 @@ static void processEvent(XEvent *event) // the position into root (screen) coordinates if (!event->xany.send_event && window->x11.parent != _glfw.x11.root) { + _glfwGrabErrorHandlerX11(); + Window dummy; XTranslateCoordinates(_glfw.x11.display, window->x11.parent, @@ -1554,6 +1556,10 @@ static void processEvent(XEvent *event) xpos, ypos, &xpos, &ypos, &dummy); + + _glfwReleaseErrorHandlerX11(); + if (_glfw.x11.errorCode == BadWindow) + return; } if (xpos != window->x11.xpos || ypos != window->x11.ypos) From a41a58a95e2ba8c2db8a2438aaa14b09f118e099 Mon Sep 17 00:00:00 2001 From: Ali Sherief <42585895+ZenulAbidin@users.noreply.github.com> Date: Thu, 21 Nov 2019 16:49:44 +0200 Subject: [PATCH 216/942] X11: Fix function keys mapped to GLFW_KEY_UNKNOWN This fixes the issue where function keys would be reported as GLFW_KEY_UNKNOWN if XKB was available and one of the configured keyboard layouts was Arabic. This is only part of #1598, because the full patch removed parts of the fallback path for when XKB is unavailable. Closes #1598. --- src/x11_init.c | 110 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 35 deletions(-) diff --git a/src/x11_init.c b/src/x11_init.c index c6ba3a19..18be952a 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -47,37 +47,6 @@ static int translateKeyCode(int scancode) if (scancode < 8 || scancode > 255) return GLFW_KEY_UNKNOWN; - if (_glfw.x11.xkb.available) - { - // Try secondary keysym, for numeric keypad keys - // 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, _glfw.x11.xkb.group, 1); - switch (keySym) - { - case XK_KP_0: return GLFW_KEY_KP_0; - case XK_KP_1: return GLFW_KEY_KP_1; - case XK_KP_2: return GLFW_KEY_KP_2; - case XK_KP_3: return GLFW_KEY_KP_3; - case XK_KP_4: return GLFW_KEY_KP_4; - case XK_KP_5: return GLFW_KEY_KP_5; - case XK_KP_6: return GLFW_KEY_KP_6; - case XK_KP_7: return GLFW_KEY_KP_7; - case XK_KP_8: return GLFW_KEY_KP_8; - case XK_KP_9: return GLFW_KEY_KP_9; - case XK_KP_Separator: - case XK_KP_Decimal: return GLFW_KEY_KP_DECIMAL; - case XK_KP_Equal: return GLFW_KEY_KP_EQUAL; - case XK_KP_Enter: return GLFW_KEY_KP_ENTER; - default: break; - } - - // 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, _glfw.x11.xkb.group, 0); - } - else { int dummy; KeySym* keySyms; @@ -251,10 +220,10 @@ static void createKeyTables(void) memcpy(name, desc->names->keys[scancode].name, XkbKeyNameLength); name[XkbKeyNameLength] = '\0'; - // Map the key name to a GLFW key code. Note: We only map printable - // keys here, and we use the US keyboard layout. The rest of the - // keys (function keys) are mapped using traditional KeySym - // translations. + // Map the key name to a GLFW key code. Note: We use the US + // keyboard layout. Because function keys aren't mapped correctly + // when using traditional KeySym translations, they are mapped + // here instead. if (strcmp(name, "TLDE") == 0) key = GLFW_KEY_GRAVE_ACCENT; else if (strcmp(name, "AE01") == 0) key = GLFW_KEY_1; else if (strcmp(name, "AE02") == 0) key = GLFW_KEY_2; @@ -303,6 +272,77 @@ static void createKeyTables(void) else if (strcmp(name, "AB10") == 0) key = GLFW_KEY_SLASH; else if (strcmp(name, "BKSL") == 0) key = GLFW_KEY_BACKSLASH; else if (strcmp(name, "LSGT") == 0) key = GLFW_KEY_WORLD_1; + else if (strcmp(name, "SPCE") == 0) key = GLFW_KEY_SPACE; + else if (strcmp(name, "ESC") == 0) key = GLFW_KEY_ESCAPE; + else if (strcmp(name, "RTRN") == 0) key = GLFW_KEY_ENTER; + else if (strcmp(name, "TAB") == 0) key = GLFW_KEY_TAB; + else if (strcmp(name, "BKSP") == 0) key = GLFW_KEY_BACKSPACE; + else if (strcmp(name, "INS") == 0) key = GLFW_KEY_INSERT; + else if (strcmp(name, "DELE") == 0) key = GLFW_KEY_DELETE; + else if (strcmp(name, "RGHT") == 0) key = GLFW_KEY_RIGHT; + else if (strcmp(name, "LEFT") == 0) key = GLFW_KEY_LEFT; + else if (strcmp(name, "DOWN") == 0) key = GLFW_KEY_DOWN; + else if (strcmp(name, "UP") == 0) key = GLFW_KEY_UP; + else if (strcmp(name, "PGUP") == 0) key = GLFW_KEY_PAGE_UP; + else if (strcmp(name, "PGDN") == 0) key = GLFW_KEY_PAGE_DOWN; + else if (strcmp(name, "HOME") == 0) key = GLFW_KEY_HOME; + else if (strcmp(name, "END") == 0) key = GLFW_KEY_END; + else if (strcmp(name, "CAPS") == 0) key = GLFW_KEY_CAPS_LOCK; + else if (strcmp(name, "SCLK") == 0) key = GLFW_KEY_SCROLL_LOCK; + else if (strcmp(name, "NMLK") == 0) key = GLFW_KEY_NUM_LOCK; + else if (strcmp(name, "PRSC") == 0) key = GLFW_KEY_PRINT_SCREEN; + else if (strcmp(name, "PAUS") == 0) key = GLFW_KEY_PAUSE; + else if (strcmp(name, "FK01") == 0) key = GLFW_KEY_F1; + else if (strcmp(name, "FK02") == 0) key = GLFW_KEY_F2; + else if (strcmp(name, "FK03") == 0) key = GLFW_KEY_F3; + else if (strcmp(name, "FK04") == 0) key = GLFW_KEY_F4; + else if (strcmp(name, "FK05") == 0) key = GLFW_KEY_F5; + else if (strcmp(name, "FK06") == 0) key = GLFW_KEY_F6; + else if (strcmp(name, "FK07") == 0) key = GLFW_KEY_F7; + else if (strcmp(name, "FK08") == 0) key = GLFW_KEY_F8; + else if (strcmp(name, "FK09") == 0) key = GLFW_KEY_F9; + else if (strcmp(name, "FK10") == 0) key = GLFW_KEY_F10; + else if (strcmp(name, "FK11") == 0) key = GLFW_KEY_F11; + else if (strcmp(name, "FK12") == 0) key = GLFW_KEY_F12; + else if (strcmp(name, "FK13") == 0) key = GLFW_KEY_F13; + else if (strcmp(name, "FK14") == 0) key = GLFW_KEY_F14; + else if (strcmp(name, "FK15") == 0) key = GLFW_KEY_F15; + else if (strcmp(name, "FK16") == 0) key = GLFW_KEY_F16; + else if (strcmp(name, "FK17") == 0) key = GLFW_KEY_F17; + else if (strcmp(name, "FK18") == 0) key = GLFW_KEY_F18; + else if (strcmp(name, "FK19") == 0) key = GLFW_KEY_F19; + else if (strcmp(name, "FK20") == 0) key = GLFW_KEY_F20; + else if (strcmp(name, "FK21") == 0) key = GLFW_KEY_F21; + else if (strcmp(name, "FK22") == 0) key = GLFW_KEY_F22; + else if (strcmp(name, "FK23") == 0) key = GLFW_KEY_F23; + else if (strcmp(name, "FK24") == 0) key = GLFW_KEY_F24; + else if (strcmp(name, "FK25") == 0) key = GLFW_KEY_F25; + else if (strcmp(name, "KP0") == 0) key = GLFW_KEY_KP_0; + else if (strcmp(name, "KP1") == 0) key = GLFW_KEY_KP_1; + else if (strcmp(name, "KP2") == 0) key = GLFW_KEY_KP_2; + else if (strcmp(name, "KP3") == 0) key = GLFW_KEY_KP_3; + else if (strcmp(name, "KP4") == 0) key = GLFW_KEY_KP_4; + else if (strcmp(name, "KP5") == 0) key = GLFW_KEY_KP_5; + else if (strcmp(name, "KP6") == 0) key = GLFW_KEY_KP_6; + else if (strcmp(name, "KP7") == 0) key = GLFW_KEY_KP_7; + else if (strcmp(name, "KP8") == 0) key = GLFW_KEY_KP_8; + else if (strcmp(name, "KP9") == 0) key = GLFW_KEY_KP_9; + else if (strcmp(name, "KPDL") == 0) key = GLFW_KEY_KP_DECIMAL; + else if (strcmp(name, "KPDV") == 0) key = GLFW_KEY_KP_DIVIDE; + else if (strcmp(name, "KPMU") == 0) key = GLFW_KEY_KP_MULTIPLY; + else if (strcmp(name, "KPSU") == 0) key = GLFW_KEY_KP_SUBTRACT; + else if (strcmp(name, "KPAD") == 0) key = GLFW_KEY_KP_ADD; + else if (strcmp(name, "KPEN") == 0) key = GLFW_KEY_KP_ENTER; + else if (strcmp(name, "KPEQ") == 0) key = GLFW_KEY_KP_EQUAL; + else if (strcmp(name, "LFSH") == 0) key = GLFW_KEY_LEFT_SHIFT; + else if (strcmp(name, "LCTL") == 0) key = GLFW_KEY_LEFT_CONTROL; + else if (strcmp(name, "LALT") == 0) key = GLFW_KEY_LEFT_ALT; + else if (strcmp(name, "LWIN") == 0) key = GLFW_KEY_LEFT_SUPER; + else if (strcmp(name, "RTSH") == 0) key = GLFW_KEY_RIGHT_SHIFT; + else if (strcmp(name, "RCTL") == 0) key = GLFW_KEY_RIGHT_CONTROL; + else if (strcmp(name, "RALT") == 0) key = GLFW_KEY_RIGHT_ALT; + else if (strcmp(name, "RWIN") == 0) key = GLFW_KEY_RIGHT_SUPER; + else if (strcmp(name, "COMP") == 0) key = GLFW_KEY_MENU; else key = GLFW_KEY_UNKNOWN; if ((scancode >= 0) && (scancode < 256)) From 215a05af3d76f58391f5b1e533630fb84f7478cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 31 Mar 2020 17:30:22 +0200 Subject: [PATCH 217/942] Update changelog and add credit Related to #1598. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 3fc111ff..c30e8a47 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,10 @@ information on what to include when reporting a bug. - [X11] Bugfix: Xlib errors caused by other parts of the application could be reported as GLFW errors - [X11] Bugfix: A handle race condition could cause a `BadWindow` error (#1633) + - [X11] Bugfix: XKB path used keysyms instead of physical locations for + non-printable keys (#1598) + - [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout + combinaitons (#1598) - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled @@ -355,6 +359,7 @@ skills. - Matt Sealey - Steve Sexton - Arkady Shapkin + - Ali Sherief - Yoshiki Shibukawa - Dmitri Shuralyov - Daniel Skorupski From ee45b58647475ceec10255d12f2c9986d259599a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 17 Mar 2020 00:04:48 +0100 Subject: [PATCH 218/942] X11: Fix X keycode ranges for XKB and core This replaces the hardcoded keycode ranges and various kludgy range checks with the actual ranges reported by Xlib and XKB. --- src/x11_init.c | 20 +++++++++++--------- src/x11_platform.h | 3 +++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/x11_init.c b/src/x11_init.c index 18be952a..ed11bd5a 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -43,10 +43,6 @@ static int translateKeyCode(int scancode) { int keySym; - // Valid key code range is [8,255], according to the Xlib manual - if (scancode < 8 || scancode > 255) - return GLFW_KEY_UNKNOWN; - { int dummy; KeySym* keySyms; @@ -200,7 +196,7 @@ static int translateKeyCode(int scancode) // static void createKeyTables(void) { - int scancode, key; + int scancode, key, scancodeMin, scancodeMax; memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes)); memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes)); @@ -214,8 +210,11 @@ static void createKeyTables(void) XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd); XkbGetNames(_glfw.x11.display, XkbKeyNamesMask, desc); + scancodeMin = desc->min_key_code; + scancodeMax = desc->max_key_code; + // Find the X11 key code -> GLFW key code mapping - for (scancode = desc->min_key_code; scancode <= desc->max_key_code; scancode++) + for (scancode = scancodeMin; scancode <= scancodeMax; scancode++) { memcpy(name, desc->names->keys[scancode].name, XkbKeyNameLength); name[XkbKeyNameLength] = '\0'; @@ -345,15 +344,16 @@ static void createKeyTables(void) else if (strcmp(name, "COMP") == 0) key = GLFW_KEY_MENU; else key = GLFW_KEY_UNKNOWN; - if ((scancode >= 0) && (scancode < 256)) - _glfw.x11.keycodes[scancode] = key; + _glfw.x11.keycodes[scancode] = key; } XkbFreeNames(desc, XkbKeyNamesMask, True); XkbFreeKeyboard(desc, 0, True); } + else + XDisplayKeycodes(_glfw.x11.display, &scancodeMin, &scancodeMax); - for (scancode = 0; scancode < 256; scancode++) + for (scancode = scancodeMin; scancode <= scancodeMax; scancode++) { // Translate the un-translated key codes using traditional X11 KeySym // lookups @@ -1069,6 +1069,8 @@ int _glfwPlatformInit(void) _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyIC"); _glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow) _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyWindow"); + _glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes) + _glfw_dlsym(_glfw.x11.xlib.handle, "XDisplayKeycodes"); _glfw.x11.xlib.EventsQueued = (PFN_XEventsQueued) _glfw_dlsym(_glfw.x11.xlib.handle, "XEventsQueued"); _glfw.x11.xlib.FilterEvent = (PFN_XFilterEvent) diff --git a/src/x11_platform.h b/src/x11_platform.h index 43a0ce19..fe82a72b 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -67,6 +67,7 @@ typedef int (* PFN_XDeleteContext)(Display*,XID,XContext); typedef int (* PFN_XDeleteProperty)(Display*,Window,Atom); typedef void (* PFN_XDestroyIC)(XIC); typedef int (* PFN_XDestroyWindow)(Display*,Window); +typedef int (* PFN_XDisplayKeycodes)(Display*,int*,int*); typedef int (* PFN_XEventsQueued)(Display*,int); typedef Bool (* PFN_XFilterEvent)(XEvent*,Window); typedef int (* PFN_XFindContext)(Display*,XID,XContext,XPointer*); @@ -166,6 +167,7 @@ typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char #define XDeleteProperty _glfw.x11.xlib.DeleteProperty #define XDestroyIC _glfw.x11.xlib.DestroyIC #define XDestroyWindow _glfw.x11.xlib.DestroyWindow +#define XDisplayKeycodes _glfw.x11.xlib.DisplayKeycodes #define XEventsQueued _glfw.x11.xlib.EventsQueued #define XFilterEvent _glfw.x11.xlib.FilterEvent #define XFindContext _glfw.x11.xlib.FindContext @@ -522,6 +524,7 @@ typedef struct _GLFWlibraryX11 PFN_XDeleteProperty DeleteProperty; PFN_XDestroyIC DestroyIC; PFN_XDestroyWindow DestroyWindow; + PFN_XDisplayKeycodes DisplayKeycodes; PFN_XEventsQueued EventsQueued; PFN_XFilterEvent FilterEvent; PFN_XFindContext FindContext; From 9ecacf1d7fb782c326bc3c47c25b44fecd6c6677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Mar 2020 18:16:15 +0100 Subject: [PATCH 219/942] X11: Check XKB key aliases in addition to names --- src/x11_init.c | 290 ++++++++++++++++++++++++++++--------------------- 1 file changed, 165 insertions(+), 125 deletions(-) diff --git a/src/x11_init.c b/src/x11_init.c index ed11bd5a..1a3ec186 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -196,7 +196,7 @@ static int translateKeyCode(int scancode) // static void createKeyTables(void) { - int scancode, key, scancodeMin, scancodeMax; + int scancode, scancodeMin, scancodeMax; memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes)); memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes)); @@ -206,143 +206,183 @@ static void createKeyTables(void) // Use XKB to determine physical key locations independently of the // current keyboard layout - char name[XkbKeyNameLength + 1]; XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd); - XkbGetNames(_glfw.x11.display, XkbKeyNamesMask, desc); + XkbGetNames(_glfw.x11.display, XkbKeyNamesMask | XkbKeyAliasesMask, desc); scancodeMin = desc->min_key_code; scancodeMax = desc->max_key_code; + const struct + { + int key; + char* name; + } keymap[] = + { + { GLFW_KEY_GRAVE_ACCENT, "TLDE" }, + { GLFW_KEY_1, "AE01" }, + { GLFW_KEY_2, "AE02" }, + { GLFW_KEY_3, "AE03" }, + { GLFW_KEY_4, "AE04" }, + { GLFW_KEY_5, "AE05" }, + { GLFW_KEY_6, "AE06" }, + { GLFW_KEY_7, "AE07" }, + { GLFW_KEY_8, "AE08" }, + { GLFW_KEY_9, "AE09" }, + { GLFW_KEY_0, "AE10" }, + { GLFW_KEY_MINUS, "AE11" }, + { GLFW_KEY_EQUAL, "AE12" }, + { GLFW_KEY_Q, "AD01" }, + { GLFW_KEY_W, "AD02" }, + { GLFW_KEY_E, "AD03" }, + { GLFW_KEY_R, "AD04" }, + { GLFW_KEY_T, "AD05" }, + { GLFW_KEY_Y, "AD06" }, + { GLFW_KEY_U, "AD07" }, + { GLFW_KEY_I, "AD08" }, + { GLFW_KEY_O, "AD09" }, + { GLFW_KEY_P, "AD10" }, + { GLFW_KEY_LEFT_BRACKET, "AD11" }, + { GLFW_KEY_RIGHT_BRACKET, "AD12" }, + { GLFW_KEY_A, "AC01" }, + { GLFW_KEY_S, "AC02" }, + { GLFW_KEY_D, "AC03" }, + { GLFW_KEY_F, "AC04" }, + { GLFW_KEY_G, "AC05" }, + { GLFW_KEY_H, "AC06" }, + { GLFW_KEY_J, "AC07" }, + { GLFW_KEY_K, "AC08" }, + { GLFW_KEY_L, "AC09" }, + { GLFW_KEY_SEMICOLON, "AC10" }, + { GLFW_KEY_APOSTROPHE, "AC11" }, + { GLFW_KEY_Z, "AB01" }, + { GLFW_KEY_X, "AB02" }, + { GLFW_KEY_C, "AB03" }, + { GLFW_KEY_V, "AB04" }, + { GLFW_KEY_B, "AB05" }, + { GLFW_KEY_N, "AB06" }, + { GLFW_KEY_M, "AB07" }, + { GLFW_KEY_COMMA, "AB08" }, + { GLFW_KEY_PERIOD, "AB09" }, + { GLFW_KEY_SLASH, "AB10" }, + { GLFW_KEY_BACKSLASH, "BKSL" }, + { GLFW_KEY_WORLD_1, "LSGT" }, + { GLFW_KEY_SPACE, "SPCE" }, + { GLFW_KEY_ESCAPE, "ESC" }, + { GLFW_KEY_ENTER, "RTRN" }, + { GLFW_KEY_TAB, "TAB" }, + { GLFW_KEY_BACKSPACE, "BKSP" }, + { GLFW_KEY_INSERT, "INS" }, + { GLFW_KEY_DELETE, "DELE" }, + { GLFW_KEY_RIGHT, "RGHT" }, + { GLFW_KEY_LEFT, "LEFT" }, + { GLFW_KEY_DOWN, "DOWN" }, + { GLFW_KEY_UP, "UP" }, + { GLFW_KEY_PAGE_UP, "PGUP" }, + { GLFW_KEY_PAGE_DOWN, "PGDN" }, + { GLFW_KEY_HOME, "HOME" }, + { GLFW_KEY_END, "END" }, + { GLFW_KEY_CAPS_LOCK, "CAPS" }, + { GLFW_KEY_SCROLL_LOCK, "SCLK" }, + { GLFW_KEY_NUM_LOCK, "NMLK" }, + { GLFW_KEY_PRINT_SCREEN, "PRSC" }, + { GLFW_KEY_PAUSE, "PAUS" }, + { GLFW_KEY_F1, "FK01" }, + { GLFW_KEY_F2, "FK02" }, + { GLFW_KEY_F3, "FK03" }, + { GLFW_KEY_F4, "FK04" }, + { GLFW_KEY_F5, "FK05" }, + { GLFW_KEY_F6, "FK06" }, + { GLFW_KEY_F7, "FK07" }, + { GLFW_KEY_F8, "FK08" }, + { GLFW_KEY_F9, "FK09" }, + { GLFW_KEY_F10, "FK10" }, + { GLFW_KEY_F11, "FK11" }, + { GLFW_KEY_F12, "FK12" }, + { GLFW_KEY_F13, "FK13" }, + { GLFW_KEY_F14, "FK14" }, + { GLFW_KEY_F15, "FK15" }, + { GLFW_KEY_F16, "FK16" }, + { GLFW_KEY_F17, "FK17" }, + { GLFW_KEY_F18, "FK18" }, + { GLFW_KEY_F19, "FK19" }, + { GLFW_KEY_F20, "FK20" }, + { GLFW_KEY_F21, "FK21" }, + { GLFW_KEY_F22, "FK22" }, + { GLFW_KEY_F23, "FK23" }, + { GLFW_KEY_F24, "FK24" }, + { GLFW_KEY_F25, "FK25" }, + { GLFW_KEY_KP_0, "KP0" }, + { GLFW_KEY_KP_1, "KP1" }, + { GLFW_KEY_KP_2, "KP2" }, + { GLFW_KEY_KP_3, "KP3" }, + { GLFW_KEY_KP_4, "KP4" }, + { GLFW_KEY_KP_5, "KP5" }, + { GLFW_KEY_KP_6, "KP6" }, + { GLFW_KEY_KP_7, "KP7" }, + { GLFW_KEY_KP_8, "KP8" }, + { GLFW_KEY_KP_9, "KP9" }, + { GLFW_KEY_KP_DECIMAL, "KPDL" }, + { GLFW_KEY_KP_DIVIDE, "KPDV" }, + { GLFW_KEY_KP_MULTIPLY, "KPMU" }, + { GLFW_KEY_KP_SUBTRACT, "KPSU" }, + { GLFW_KEY_KP_ADD, "KPAD" }, + { GLFW_KEY_KP_ENTER, "KPEN" }, + { GLFW_KEY_KP_EQUAL, "KPEQ" }, + { GLFW_KEY_LEFT_SHIFT, "LFSH" }, + { GLFW_KEY_LEFT_CONTROL, "LCTL" }, + { GLFW_KEY_LEFT_ALT, "LALT" }, + { GLFW_KEY_LEFT_SUPER, "LWIN" }, + { GLFW_KEY_RIGHT_SHIFT, "RTSH" }, + { GLFW_KEY_RIGHT_CONTROL, "RCTL" }, + { GLFW_KEY_RIGHT_ALT, "RALT" }, + { GLFW_KEY_RIGHT_SUPER, "RWIN" }, + { GLFW_KEY_MENU, "COMP" } + }; + // Find the X11 key code -> GLFW key code mapping for (scancode = scancodeMin; scancode <= scancodeMax; scancode++) { - memcpy(name, desc->names->keys[scancode].name, XkbKeyNameLength); - name[XkbKeyNameLength] = '\0'; + int key = GLFW_KEY_UNKNOWN; // Map the key name to a GLFW key code. Note: We use the US // keyboard layout. Because function keys aren't mapped correctly // when using traditional KeySym translations, they are mapped // here instead. - if (strcmp(name, "TLDE") == 0) key = GLFW_KEY_GRAVE_ACCENT; - else if (strcmp(name, "AE01") == 0) key = GLFW_KEY_1; - else if (strcmp(name, "AE02") == 0) key = GLFW_KEY_2; - else if (strcmp(name, "AE03") == 0) key = GLFW_KEY_3; - else if (strcmp(name, "AE04") == 0) key = GLFW_KEY_4; - else if (strcmp(name, "AE05") == 0) key = GLFW_KEY_5; - else if (strcmp(name, "AE06") == 0) key = GLFW_KEY_6; - else if (strcmp(name, "AE07") == 0) key = GLFW_KEY_7; - else if (strcmp(name, "AE08") == 0) key = GLFW_KEY_8; - else if (strcmp(name, "AE09") == 0) key = GLFW_KEY_9; - else if (strcmp(name, "AE10") == 0) key = GLFW_KEY_0; - else if (strcmp(name, "AE11") == 0) key = GLFW_KEY_MINUS; - else if (strcmp(name, "AE12") == 0) key = GLFW_KEY_EQUAL; - else if (strcmp(name, "AD01") == 0) key = GLFW_KEY_Q; - else if (strcmp(name, "AD02") == 0) key = GLFW_KEY_W; - else if (strcmp(name, "AD03") == 0) key = GLFW_KEY_E; - else if (strcmp(name, "AD04") == 0) key = GLFW_KEY_R; - else if (strcmp(name, "AD05") == 0) key = GLFW_KEY_T; - else if (strcmp(name, "AD06") == 0) key = GLFW_KEY_Y; - else if (strcmp(name, "AD07") == 0) key = GLFW_KEY_U; - else if (strcmp(name, "AD08") == 0) key = GLFW_KEY_I; - else if (strcmp(name, "AD09") == 0) key = GLFW_KEY_O; - else if (strcmp(name, "AD10") == 0) key = GLFW_KEY_P; - else if (strcmp(name, "AD11") == 0) key = GLFW_KEY_LEFT_BRACKET; - else if (strcmp(name, "AD12") == 0) key = GLFW_KEY_RIGHT_BRACKET; - else if (strcmp(name, "AC01") == 0) key = GLFW_KEY_A; - else if (strcmp(name, "AC02") == 0) key = GLFW_KEY_S; - else if (strcmp(name, "AC03") == 0) key = GLFW_KEY_D; - else if (strcmp(name, "AC04") == 0) key = GLFW_KEY_F; - else if (strcmp(name, "AC05") == 0) key = GLFW_KEY_G; - else if (strcmp(name, "AC06") == 0) key = GLFW_KEY_H; - else if (strcmp(name, "AC07") == 0) key = GLFW_KEY_J; - else if (strcmp(name, "AC08") == 0) key = GLFW_KEY_K; - else if (strcmp(name, "AC09") == 0) key = GLFW_KEY_L; - else if (strcmp(name, "AC10") == 0) key = GLFW_KEY_SEMICOLON; - else if (strcmp(name, "AC11") == 0) key = GLFW_KEY_APOSTROPHE; - else if (strcmp(name, "AB01") == 0) key = GLFW_KEY_Z; - else if (strcmp(name, "AB02") == 0) key = GLFW_KEY_X; - else if (strcmp(name, "AB03") == 0) key = GLFW_KEY_C; - else if (strcmp(name, "AB04") == 0) key = GLFW_KEY_V; - else if (strcmp(name, "AB05") == 0) key = GLFW_KEY_B; - else if (strcmp(name, "AB06") == 0) key = GLFW_KEY_N; - else if (strcmp(name, "AB07") == 0) key = GLFW_KEY_M; - else if (strcmp(name, "AB08") == 0) key = GLFW_KEY_COMMA; - else if (strcmp(name, "AB09") == 0) key = GLFW_KEY_PERIOD; - else if (strcmp(name, "AB10") == 0) key = GLFW_KEY_SLASH; - else if (strcmp(name, "BKSL") == 0) key = GLFW_KEY_BACKSLASH; - else if (strcmp(name, "LSGT") == 0) key = GLFW_KEY_WORLD_1; - else if (strcmp(name, "SPCE") == 0) key = GLFW_KEY_SPACE; - else if (strcmp(name, "ESC") == 0) key = GLFW_KEY_ESCAPE; - else if (strcmp(name, "RTRN") == 0) key = GLFW_KEY_ENTER; - else if (strcmp(name, "TAB") == 0) key = GLFW_KEY_TAB; - else if (strcmp(name, "BKSP") == 0) key = GLFW_KEY_BACKSPACE; - else if (strcmp(name, "INS") == 0) key = GLFW_KEY_INSERT; - else if (strcmp(name, "DELE") == 0) key = GLFW_KEY_DELETE; - else if (strcmp(name, "RGHT") == 0) key = GLFW_KEY_RIGHT; - else if (strcmp(name, "LEFT") == 0) key = GLFW_KEY_LEFT; - else if (strcmp(name, "DOWN") == 0) key = GLFW_KEY_DOWN; - else if (strcmp(name, "UP") == 0) key = GLFW_KEY_UP; - else if (strcmp(name, "PGUP") == 0) key = GLFW_KEY_PAGE_UP; - else if (strcmp(name, "PGDN") == 0) key = GLFW_KEY_PAGE_DOWN; - else if (strcmp(name, "HOME") == 0) key = GLFW_KEY_HOME; - else if (strcmp(name, "END") == 0) key = GLFW_KEY_END; - else if (strcmp(name, "CAPS") == 0) key = GLFW_KEY_CAPS_LOCK; - else if (strcmp(name, "SCLK") == 0) key = GLFW_KEY_SCROLL_LOCK; - else if (strcmp(name, "NMLK") == 0) key = GLFW_KEY_NUM_LOCK; - else if (strcmp(name, "PRSC") == 0) key = GLFW_KEY_PRINT_SCREEN; - else if (strcmp(name, "PAUS") == 0) key = GLFW_KEY_PAUSE; - else if (strcmp(name, "FK01") == 0) key = GLFW_KEY_F1; - else if (strcmp(name, "FK02") == 0) key = GLFW_KEY_F2; - else if (strcmp(name, "FK03") == 0) key = GLFW_KEY_F3; - else if (strcmp(name, "FK04") == 0) key = GLFW_KEY_F4; - else if (strcmp(name, "FK05") == 0) key = GLFW_KEY_F5; - else if (strcmp(name, "FK06") == 0) key = GLFW_KEY_F6; - else if (strcmp(name, "FK07") == 0) key = GLFW_KEY_F7; - else if (strcmp(name, "FK08") == 0) key = GLFW_KEY_F8; - else if (strcmp(name, "FK09") == 0) key = GLFW_KEY_F9; - else if (strcmp(name, "FK10") == 0) key = GLFW_KEY_F10; - else if (strcmp(name, "FK11") == 0) key = GLFW_KEY_F11; - else if (strcmp(name, "FK12") == 0) key = GLFW_KEY_F12; - else if (strcmp(name, "FK13") == 0) key = GLFW_KEY_F13; - else if (strcmp(name, "FK14") == 0) key = GLFW_KEY_F14; - else if (strcmp(name, "FK15") == 0) key = GLFW_KEY_F15; - else if (strcmp(name, "FK16") == 0) key = GLFW_KEY_F16; - else if (strcmp(name, "FK17") == 0) key = GLFW_KEY_F17; - else if (strcmp(name, "FK18") == 0) key = GLFW_KEY_F18; - else if (strcmp(name, "FK19") == 0) key = GLFW_KEY_F19; - else if (strcmp(name, "FK20") == 0) key = GLFW_KEY_F20; - else if (strcmp(name, "FK21") == 0) key = GLFW_KEY_F21; - else if (strcmp(name, "FK22") == 0) key = GLFW_KEY_F22; - else if (strcmp(name, "FK23") == 0) key = GLFW_KEY_F23; - else if (strcmp(name, "FK24") == 0) key = GLFW_KEY_F24; - else if (strcmp(name, "FK25") == 0) key = GLFW_KEY_F25; - else if (strcmp(name, "KP0") == 0) key = GLFW_KEY_KP_0; - else if (strcmp(name, "KP1") == 0) key = GLFW_KEY_KP_1; - else if (strcmp(name, "KP2") == 0) key = GLFW_KEY_KP_2; - else if (strcmp(name, "KP3") == 0) key = GLFW_KEY_KP_3; - else if (strcmp(name, "KP4") == 0) key = GLFW_KEY_KP_4; - else if (strcmp(name, "KP5") == 0) key = GLFW_KEY_KP_5; - else if (strcmp(name, "KP6") == 0) key = GLFW_KEY_KP_6; - else if (strcmp(name, "KP7") == 0) key = GLFW_KEY_KP_7; - else if (strcmp(name, "KP8") == 0) key = GLFW_KEY_KP_8; - else if (strcmp(name, "KP9") == 0) key = GLFW_KEY_KP_9; - else if (strcmp(name, "KPDL") == 0) key = GLFW_KEY_KP_DECIMAL; - else if (strcmp(name, "KPDV") == 0) key = GLFW_KEY_KP_DIVIDE; - else if (strcmp(name, "KPMU") == 0) key = GLFW_KEY_KP_MULTIPLY; - else if (strcmp(name, "KPSU") == 0) key = GLFW_KEY_KP_SUBTRACT; - else if (strcmp(name, "KPAD") == 0) key = GLFW_KEY_KP_ADD; - else if (strcmp(name, "KPEN") == 0) key = GLFW_KEY_KP_ENTER; - else if (strcmp(name, "KPEQ") == 0) key = GLFW_KEY_KP_EQUAL; - else if (strcmp(name, "LFSH") == 0) key = GLFW_KEY_LEFT_SHIFT; - else if (strcmp(name, "LCTL") == 0) key = GLFW_KEY_LEFT_CONTROL; - else if (strcmp(name, "LALT") == 0) key = GLFW_KEY_LEFT_ALT; - else if (strcmp(name, "LWIN") == 0) key = GLFW_KEY_LEFT_SUPER; - else if (strcmp(name, "RTSH") == 0) key = GLFW_KEY_RIGHT_SHIFT; - else if (strcmp(name, "RCTL") == 0) key = GLFW_KEY_RIGHT_CONTROL; - else if (strcmp(name, "RALT") == 0) key = GLFW_KEY_RIGHT_ALT; - else if (strcmp(name, "RWIN") == 0) key = GLFW_KEY_RIGHT_SUPER; - else if (strcmp(name, "COMP") == 0) key = GLFW_KEY_MENU; - else key = GLFW_KEY_UNKNOWN; + for (int i = 0; i < sizeof(keymap) / sizeof(keymap[0]); i++) + { + if (strncmp(desc->names->keys[scancode].name, + keymap[i].name, + XkbKeyNameLength) == 0) + { + key = keymap[i].key; + break; + } + } + + // Fall back to key aliases in case the key name did not match + for (int i = 0; i < desc->names->num_key_aliases; i++) + { + if (key != GLFW_KEY_UNKNOWN) + break; + + if (strncmp(desc->names->key_aliases[i].real, + desc->names->keys[scancode].name, + XkbKeyNameLength) != 0) + { + continue; + } + + for (int j = 0; j < sizeof(keymap) / sizeof(keymap[0]); j++) + { + if (strncmp(desc->names->key_aliases[i].alias, + keymap[j].name, + XkbKeyNameLength) == 0) + { + key = keymap[j].key; + break; + } + } + } _glfw.x11.keycodes[scancode] = key; } From 560304e0f4250fb979e65de00b6c8ce3b9fd6b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 31 Mar 2020 17:00:43 +0200 Subject: [PATCH 220/942] X11: Use XKB key name MENU for Menu key --- src/x11_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x11_init.c b/src/x11_init.c index 1a3ec186..4f1bef9c 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -336,7 +336,7 @@ static void createKeyTables(void) { GLFW_KEY_RIGHT_CONTROL, "RCTL" }, { GLFW_KEY_RIGHT_ALT, "RALT" }, { GLFW_KEY_RIGHT_SUPER, "RWIN" }, - { GLFW_KEY_MENU, "COMP" } + { GLFW_KEY_MENU, "MENU" } }; // Find the X11 key code -> GLFW key code mapping From 318e08d914e7e1893800d7d61a7188697b13bce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 23 Apr 2020 17:42:36 +0200 Subject: [PATCH 221/942] X11: Add additional XKB key names for Right Alt --- src/x11_init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/x11_init.c b/src/x11_init.c index 4f1bef9c..84906183 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -335,6 +335,8 @@ static void createKeyTables(void) { GLFW_KEY_RIGHT_SHIFT, "RTSH" }, { GLFW_KEY_RIGHT_CONTROL, "RCTL" }, { GLFW_KEY_RIGHT_ALT, "RALT" }, + { GLFW_KEY_RIGHT_ALT, "LVL3" }, + { GLFW_KEY_RIGHT_ALT, "MDSW" }, { GLFW_KEY_RIGHT_SUPER, "RWIN" }, { GLFW_KEY_MENU, "MENU" } }; From cab41529da42f46dc6d6aec159a9b8d1d1331652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 23 Apr 2020 21:27:28 +0200 Subject: [PATCH 222/942] X11: Improve non-XKB fallback for key mapping A regression introduced by b889aa784129b3e7d1219a55a1008bd6518183db broke the special handling of numpad keys for the non-XKB fallback path. The non-functional remains were later removed. This restores the original behavior. --- src/x11_init.c | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/src/x11_init.c b/src/x11_init.c index 84906183..e5bd578d 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -37,22 +37,35 @@ #include -// Translate an X11 key code to a GLFW key code. +// Translate the X11 KeySyms for a key to a GLFW key code +// NOTE: This is only used as a fallback, in case the XKB method fails +// It is layout-dependent and will fail partially on most non-US layouts // -static int translateKeyCode(int scancode) +static int translateKeySyms(const KeySym* keysyms, int width) { - int keySym; - + if (width > 1) { - int dummy; - KeySym* keySyms; - - keySyms = XGetKeyboardMapping(_glfw.x11.display, scancode, 1, &dummy); - keySym = keySyms[0]; - XFree(keySyms); + switch (keysyms[1]) + { + case XK_KP_0: return GLFW_KEY_KP_0; + case XK_KP_1: return GLFW_KEY_KP_1; + case XK_KP_2: return GLFW_KEY_KP_2; + case XK_KP_3: return GLFW_KEY_KP_3; + case XK_KP_4: return GLFW_KEY_KP_4; + case XK_KP_5: return GLFW_KEY_KP_5; + case XK_KP_6: return GLFW_KEY_KP_6; + case XK_KP_7: return GLFW_KEY_KP_7; + case XK_KP_8: return GLFW_KEY_KP_8; + case XK_KP_9: return GLFW_KEY_KP_9; + case XK_KP_Separator: + case XK_KP_Decimal: return GLFW_KEY_KP_DECIMAL; + case XK_KP_Equal: return GLFW_KEY_KP_EQUAL; + case XK_KP_Enter: return GLFW_KEY_KP_ENTER; + default: break; + } } - switch (keySym) + switch (keysyms[0]) { case XK_Escape: return GLFW_KEY_ESCAPE; case XK_Tab: return GLFW_KEY_TAB; @@ -395,17 +408,28 @@ static void createKeyTables(void) else XDisplayKeycodes(_glfw.x11.display, &scancodeMin, &scancodeMax); + int width; + KeySym* keysyms = XGetKeyboardMapping(_glfw.x11.display, + scancodeMin, + scancodeMax - scancodeMin + 1, + &width); + for (scancode = scancodeMin; scancode <= scancodeMax; scancode++) { // Translate the un-translated key codes using traditional X11 KeySym // lookups if (_glfw.x11.keycodes[scancode] < 0) - _glfw.x11.keycodes[scancode] = translateKeyCode(scancode); + { + const size_t base = (scancode - scancodeMin) * width; + _glfw.x11.keycodes[scancode] = translateKeySyms(&keysyms[base], width); + } // Store the reverse translation for faster key name lookup if (_glfw.x11.keycodes[scancode] > 0) _glfw.x11.scancodes[_glfw.x11.keycodes[scancode]] = scancode; } + + XFree(keysyms); } // Check whether the IM has a usable style From 949275bbedaa58a5399c6ce5276adc190ae6a16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Apr 2020 22:12:21 +0200 Subject: [PATCH 223/942] Cocoa: Fix call to NSWindow from non-main threads glfwSwapBuffers may be called by any thread but NSWindow may not. Bug introduced by c3ca88055f7c2c8b02b38cb90fc1989990552977 and reported by @crujose. --- src/cocoa_platform.h | 1 + src/cocoa_window.m | 8 ++++++++ src/nsgl_context.m | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 90714341..b18b99cb 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -121,6 +121,7 @@ typedef struct _GLFWwindowNS id layer; GLFWbool maximized; + GLFWbool occluded; GLFWbool retina; // Cached window properties to filter out duplicate events diff --git a/src/cocoa_window.m b/src/cocoa_window.m index c50bf21a..45837dc1 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -322,6 +322,14 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputWindowFocus(window, GLFW_FALSE); } +- (void)windowDidChangeOcclusionState:(NSNotification* )notification +{ + if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible) + window->ns.occluded = GLFW_FALSE; + else + window->ns.occluded = GLFW_TRUE; +} + @end diff --git a/src/nsgl_context.m b/src/nsgl_context.m index e011fa5e..3f73f7a6 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -51,7 +51,7 @@ static void swapBuffersNSGL(_GLFWwindow* window) // 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)) + if (window->ns.occluded) { int interval = 0; [window->context.nsgl.object getValues:&interval From 41a19ed49c5ace44949f58b157714d59c2aebf2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 4 May 2020 23:18:48 +0200 Subject: [PATCH 224/942] Disambiguate Vulkan support reference link --- docs/vulkan.dox | 2 +- include/GLFW/glfw3.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/vulkan.dox b/docs/vulkan.dox index dc158d6d..767cb9ff 100644 --- a/docs/vulkan.dox +++ b/docs/vulkan.dox @@ -14,7 +14,7 @@ To develop for Vulkan you should download the [LunarG Vulkan SDK](https://vulkan.lunarg.com/) for your platform. Apart from headers and link libraries, they also provide the validation layers necessary for development. -For details on a specific function in this category, see the @ref vulkan. There +For details on a specific Vulkan support function, see the @ref vulkan. There are also guides for the other areas of the GLFW API. - @ref intro_guide diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e5b9b6c6..e077a0c4 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -52,7 +52,7 @@ extern "C" { * This is the reference documentation for OpenGL and OpenGL ES context related * functions. For more task-oriented information, see the @ref context_guide. */ -/*! @defgroup vulkan Vulkan reference +/*! @defgroup vulkan Vulkan support reference * @brief Functions and types related to Vulkan. * * This is the reference documentation for Vulkan related functions and types. From d7ae90a790416f150a39e8f42f8278598bafae29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Apr 2020 21:21:40 +0200 Subject: [PATCH 225/942] Update community resource links --- docs/build.dox | 3 +++ docs/quick.dox | 16 ++++++++++------ docs/vulkan.dox | 9 +++++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/build.dox b/docs/build.dox index 03d0fd7d..cfa5b633 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -215,6 +215,9 @@ library and include directory paths. Link against this like any other library. target_link_libraries(myapp OpenGL::GL) @endcode +For a minimal example of a program and GLFW sources built with CMake, see the +[GLFW CMake Starter](https://github.com/juliettef/GLFW-CMake-starter) on GitHub. + @subsection build_link_cmake_package With CMake and installed GLFW binaries diff --git a/docs/quick.dox b/docs/quick.dox index 17d2679a..f6db339f 100644 --- a/docs/quick.dox +++ b/docs/quick.dox @@ -251,12 +251,16 @@ glViewport(0, 0, width, height); You can also set a framebuffer size callback using @ref glfwSetFramebufferSizeCallback and be notified when the size changes. -Actual rendering with OpenGL is outside the scope of this tutorial, but there -are [many](https://open.gl/) [excellent](https://learnopengl.com/) -[tutorial](http://openglbook.com/) [sites](http://ogldev.atspace.co.uk/) that -teach modern OpenGL. Some of them use GLFW to create the context and window -while others use GLUT or SDL, but remember that OpenGL itself always works the -same. +The details of how to render with OpenGL is outside the scope of this tutorial, +but there are many excellent resources for learning modern OpenGL. Here are +a few of them: + + - [Anton's OpenGL 4 Tutorials](https://antongerdelan.net/opengl/) + - [Learn OpenGL](https://learnopengl.com/) + - [Open.GL](https://open.gl/) + +These all happen to use GLFW, but OpenGL itself works the same whatever API you +use to create the window and context. @subsection quick_timer Reading the timer diff --git a/docs/vulkan.dox b/docs/vulkan.dox index 767cb9ff..2585c2bb 100644 --- a/docs/vulkan.dox +++ b/docs/vulkan.dox @@ -4,8 +4,8 @@ @tableofcontents -This guide is intended to fill the gaps between the [Vulkan -documentation](https://www.khronos.org/vulkan/) and the rest of the GLFW +This guide is intended to fill the gaps between the official [Vulkan +resources](https://www.khronos.org/vulkan/) and the rest of the GLFW documentation and is not a replacement for either. It assumes some familiarity with Vulkan concepts like loaders, devices, queues and surfaces and leaves it to the Vulkan documentation to explain the details of Vulkan functions. @@ -14,6 +14,11 @@ To develop for Vulkan you should download the [LunarG Vulkan SDK](https://vulkan.lunarg.com/) for your platform. Apart from headers and link libraries, they also provide the validation layers necessary for development. +The [Vulkan Tutorial](https://vulkan-tutorial.com/) has more information on how +to use GLFW and Vulkan. The [Khronos Vulkan +Samples](https://github.com/KhronosGroup/Vulkan-Samples) also use GLFW, although +with a small framework in between. + For details on a specific Vulkan support function, see the @ref vulkan. There are also guides for the other areas of the GLFW API. From 67c720d117673f0e2d4625ba8463d7472bf9a71a Mon Sep 17 00:00:00 2001 From: gre-42 <63736956+gre-42@users.noreply.github.com> Date: Wed, 15 Apr 2020 18:00:11 +0200 Subject: [PATCH 226/942] Correct sign in mat4x4_rotate_Y Signs were incorrect in mat4x4_rotate_Y. Closes #1673. --- deps/linmath.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/linmath.h b/deps/linmath.h index c4c0e24e..8b2a8c2e 100644 --- a/deps/linmath.h +++ b/deps/linmath.h @@ -257,9 +257,9 @@ LINMATH_H_FUNC void mat4x4_rotate_Y(mat4x4 Q, mat4x4 M, float angle) float s = sinf(angle); float c = cosf(angle); mat4x4 R = { - { c, 0.f, s, 0.f}, + { c, 0.f, -s, 0.f}, { 0.f, 1.f, 0.f, 0.f}, - { -s, 0.f, c, 0.f}, + { s, 0.f, c, 0.f}, { 0.f, 0.f, 0.f, 1.f} }; mat4x4_mul(Q, M, R); From 844bc8031c63284ba324217b39b663a104fc4d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 May 2020 13:24:49 +0200 Subject: [PATCH 227/942] Add null platform to Travis CI --- .travis.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5f3b7393..0b6392bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,6 +69,28 @@ matrix: - USE_WAYLAND=ON - BUILD_SHARED_LIBS=OFF - CFLAGS=-Werror + - os: linux + dist: bionic + name: "Null shared library" + addons: + apt: + packages: + - libosmesa6-dev + env: + - BUILD_SHARED_LIBS=ON + - USE_OSMESA=ON + - CFLAGS=-Werror + - os: linux + dist: bionic + name: "Null static library" + addons: + apt: + packages: + - libosmesa6-dev + env: + - BUILD_SHARED_LIBS=OFF + - USE_OSMESA=ON + - CFLAGS=-Werror - os: osx sudo: false name: "Cocoa shared library" @@ -96,7 +118,7 @@ script: git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install; popd; fi - - cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DGLFW_USE_WAYLAND=${USE_WAYLAND} .. + - cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DGLFW_USE_WAYLAND=${USE_WAYLAND} -DGLFW_USE_OSMESA=${USE_OSMESA} .. - cmake --build . notifications: email: From 0c403c8ca678208d5770211257d20581730d78b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 May 2020 17:44:59 +0200 Subject: [PATCH 228/942] X11: Fix XKB group event depending on state query This fixes XKB group change events not being enabled if the initial XKB keyboard state query fails. --- src/x11_init.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/x11_init.c b/src/x11_init.c index e5bd578d..c6c72df2 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -808,10 +808,9 @@ static GLFWbool initExtensions(void) _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; - } + + XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify, XkbAllStateComponentsMask, XkbGroupStateMask); } #if defined(__CYGWIN__) From cf3a03a85d4ea031f231ca72d66228757778cc8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 May 2020 17:47:58 +0200 Subject: [PATCH 229/942] X11: Remove duplicate XKB group initialization The XKB group is already set to zero during initialization. --- src/x11_init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/x11_init.c b/src/x11_init.c index c6c72df2..76e2cc0e 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -805,7 +805,6 @@ static GLFWbool initExtensions(void) _glfw.x11.xkb.detectable = GLFW_TRUE; } - _glfw.x11.xkb.group = 0; XkbStateRec state; if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success) _glfw.x11.xkb.group = (unsigned int)state.group; From e07925c4047c4c5401369e0c6fe70bcab61e30c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 May 2020 17:49:02 +0200 Subject: [PATCH 230/942] X11: Fix XKB state event bits being overwritten This limits the update to the XKB group state event bit without clearing all other state event bits. --- src/x11_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/x11_init.c b/src/x11_init.c index 76e2cc0e..0aa0ff9a 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -809,7 +809,8 @@ static GLFWbool initExtensions(void) if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success) _glfw.x11.xkb.group = (unsigned int)state.group; - XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify, XkbAllStateComponentsMask, XkbGroupStateMask); + XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify, + XkbGroupStateMask, XkbGroupStateMask); } #if defined(__CYGWIN__) From a17a1b20115ef7c86ac1667532b67788ec8631df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 May 2020 17:55:28 +0200 Subject: [PATCH 231/942] X11: Fix XKB events being passed on to core path --- src/x11_window.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/x11_window.c b/src/x11_window.c index d6e6bf37..ec9946d1 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1185,6 +1185,8 @@ static void processEvent(XEvent *event) { _glfw.x11.xkb.group = ((XkbEvent*) event)->state.group; } + + return; } } From ef5220d6b10174d0f7cce965475e34527afcfbcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 May 2020 17:59:18 +0200 Subject: [PATCH 232/942] X11: Clarify code flow for Clang static analysis --- src/x11_window.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index ec9946d1..75f15c6d 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2001,7 +2001,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { - Visual* visual; + Visual* visual = NULL; int depth; if (ctxconfig->client != GLFW_NO_API) @@ -2027,8 +2027,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, } } - if (ctxconfig->client == GLFW_NO_API || - ctxconfig->source == GLFW_OSMESA_CONTEXT_API) + if (!visual) { visual = DefaultVisual(_glfw.x11.display, _glfw.x11.screen); depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen); From 27295b508ffd098de8673bfe5f7f4154235cb1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 May 2020 18:56:25 +0200 Subject: [PATCH 233/942] Note removal of wl_shell support in release notes --- docs/news.dox | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/news.dox b/docs/news.dox index 4dd72795..0b948356 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -69,6 +69,13 @@ needs to be specified during compilation or linking. @subsection removals_34 Removals in 3.4 +@subsubsection wl_shell_34 Support for the wl_shell protocol has been removed + +Support for the wl_shell protocol has been removed and GLFW now only supports +the XDG-Shell protocol. If your Wayland compositor does not support XDG-Shell +then GLFW will fail to initialize. + + @subsection symbols_34 New symbols in version 3.4 @subsubsection functions_34 New functions in version 3.4 From 5f9dfe3d83af4d6b95c2e4f19adadc334eb314ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 May 2020 19:03:02 +0200 Subject: [PATCH 234/942] X11: Clarify function name and comment --- src/x11_init.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/x11_init.c b/src/x11_init.c index 0aa0ff9a..3ecc7fa8 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -489,11 +489,11 @@ static void inputMethodInstantiateCallback(Display* display, } } -// Check whether the specified atom is supported +// Return the atom ID only if it is listed in the specified array // -static Atom getSupportedAtom(Atom* supportedAtoms, - unsigned long atomCount, - const char* atomName) +static Atom getAtomIfSupported(Atom* supportedAtoms, + unsigned long atomCount, + const char* atomName) { const Atom atom = XInternAtom(_glfw.x11.display, atomName, False); @@ -565,33 +565,33 @@ static void detectEWMH(void) // See which of the atoms we support that are supported by the WM _glfw.x11.NET_WM_STATE = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE"); _glfw.x11.NET_WM_STATE_ABOVE = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE"); _glfw.x11.NET_WM_STATE_FULLSCREEN = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN"); _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT"); _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ"); _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION"); _glfw.x11.NET_WM_FULLSCREEN_MONITORS = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS"); _glfw.x11.NET_WM_WINDOW_TYPE = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE"); _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL"); _glfw.x11.NET_WORKAREA = - getSupportedAtom(supportedAtoms, atomCount, "_NET_WORKAREA"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_WORKAREA"); _glfw.x11.NET_CURRENT_DESKTOP = - getSupportedAtom(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP"); _glfw.x11.NET_ACTIVE_WINDOW = - getSupportedAtom(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW"); _glfw.x11.NET_FRAME_EXTENTS = - getSupportedAtom(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS"); _glfw.x11.NET_REQUEST_FRAME_EXTENTS = - getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS"); + getAtomIfSupported(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS"); if (supportedAtoms) XFree(supportedAtoms); From 51a465ee2b50234f984efce0e229f7e9afceda9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 20 May 2020 17:59:10 +0200 Subject: [PATCH 235/942] Win32: Remove checks for pre-XP Windows Windows XP is the oldest version supported by GLFW 3.4. --- src/win32_platform.h | 3 --- src/win32_window.c | 10 +++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/win32_platform.h b/src/win32_platform.h index 2b00b001..9a0b5ad8 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -160,9 +160,6 @@ typedef enum #endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/ // HACK: Define versionhelpers.h functions manually as MinGW lacks the header -#define IsWindowsXPOrGreater() \ - _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINXP), \ - LOBYTE(_WIN32_WINNT_WINXP), 0) #define IsWindowsVistaOrGreater() \ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \ LOBYTE(_WIN32_WINNT_VISTA), 0) diff --git a/src/win32_window.c b/src/win32_window.c index 0ae0998a..ad72db9c 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -468,11 +468,8 @@ static void acquireMonitor(_GLFWwindow* window) // HACK: When mouse trails are enabled the cursor becomes invisible when // the OpenGL ICD switches to page flipping - if (IsWindowsXPOrGreater()) - { - SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0); - SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0); - } + SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0); + SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0); } if (!window->monitor->window) @@ -495,8 +492,7 @@ static void releaseMonitor(_GLFWwindow* window) SetThreadExecutionState(ES_CONTINUOUS); // HACK: Restore mouse trail length saved in acquireMonitor - if (IsWindowsXPOrGreater()) - SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0); + SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0); } _glfwInputMonitorWindow(window->monitor, NULL); From 91eebe922de06a3ed4ba6622686c436c7941aa63 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Sun, 19 Apr 2020 14:10:52 +0200 Subject: [PATCH 236/942] Use CALayer instead of NSView for EGLNativeWindowType The only two EGL implementations on macOS are Swiftshader and ANGLE. While Swiftshader supports both `NSView` and `CALayer` as `EGLNativeWindowType`, ANGLE supports only `CALayer`. Furthermore Swiftshader's OpenGL ES frontend is deprecated in favor of using ANGLE's Vulkan backend on top of Swiftshader's Vulkan frontend. This means that on macOS `EGLNativeWindowType` should be a `CALayer` for compatibility with ANGLE. Fixes #1169. Closes #1680. --- README.md | 1 + src/cocoa_platform.h | 2 +- src/cocoa_window.m | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c30e8a47..761a942b 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread would abort (#1649) + - [Cocoa] Use `CALayer` instead of `NSView` for `EGLNativeWindowType` (#1169) - [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_platform.h b/src/cocoa_platform.h index b18b99cb..b67ddd2b 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -92,7 +92,7 @@ typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMeta #define _glfw_dlclose(handle) dlclose(handle) #define _glfw_dlsym(handle, name) dlsym(handle, name) -#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view) +#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.layer) #define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 45837dc1..7b50c753 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -906,6 +906,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, } else if (ctxconfig->source == GLFW_EGL_CONTEXT_API) { + // EGL implementation on macOS use CALayer* EGLNativeWindowType so we + // need to get the layer for EGL window surface creation. + [window->ns.view setWantsLayer:YES]; + window->ns.layer = [window->ns.view layer]; + if (!_glfwInitEGL()) return GLFW_FALSE; if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) From d4f50745356fd38e30100d50418b83db24755994 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Mon, 25 May 2020 15:42:52 +0200 Subject: [PATCH 237/942] Replace %m conversion specifier with %s and strerror() When compiling with `-Wall` and `-pedantic-errors`, gcc complains with ``` warning: ISO C does not support the '%m' gnu_printf format [-Wformat=] ``` because the `%m` conversion specifier is a GNU extension. Closes #1702. --- src/wl_window.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index c8dde30a..26cb2ac1 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -142,8 +142,8 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) if (fd < 0) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Creating a buffer file for %d B failed: %m", - length); + "Wayland: Creating a buffer file for %d B failed: %s", + length, strerror(errno)); return NULL; } @@ -151,7 +151,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) if (data == MAP_FAILED) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: mmap failed: %m"); + "Wayland: mmap failed: %s", strerror(errno)); close(fd); return NULL; } From 250b94cd03e6f947ba516869c7f3b277f8d0cacc Mon Sep 17 00:00:00 2001 From: Luflosi Date: Mon, 25 May 2020 15:03:23 +0200 Subject: [PATCH 238/942] Use the correct type in a for loop The `atomCount` variable has the type `unsigned long`, so the `for` loop iterating over it should use the same type. Closes #1701. --- src/x11_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x11_init.c b/src/x11_init.c index 3ecc7fa8..5e31e16b 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -497,7 +497,7 @@ static Atom getAtomIfSupported(Atom* supportedAtoms, { const Atom atom = XInternAtom(_glfw.x11.display, atomName, False); - for (unsigned int i = 0; i < atomCount; i++) + for (unsigned long i = 0; i < atomCount; i++) { if (supportedAtoms[i] == atom) return atom; From a84a30ab6399eedd4606da226fe4f02eab3c2d2e Mon Sep 17 00:00:00 2001 From: ben1 Date: Mon, 25 May 2020 15:22:25 +1000 Subject: [PATCH 239/942] Win32: Fix VS /W4 compile warnings These are harmless errors but the code was worth fixing just to reduce confusion and be more explicit. E.g. using a different variable name for a new variable of a different type in win32_joystick.c. Closes #1700. --- src/egl_context.c | 16 +++++++--------- src/win32_joystick.c | 10 +++++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index 706a7922..819a2b2d 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -588,18 +588,16 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, } // Set up attributes for surface creation + index = 0; + + if (fbconfig->sRGB) { - int index = 0; - - if (fbconfig->sRGB) - { - if (_glfw.egl.KHR_gl_colorspace) - setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR); - } - - setAttrib(EGL_NONE, EGL_NONE); + if (_glfw.egl.KHR_gl_colorspace) + setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR); } + setAttrib(EGL_NONE, EGL_NONE); + window->context.egl.surface = eglCreateWindowSurface(_glfw.egl.display, config, diff --git a/src/win32_joystick.c b/src/win32_joystick.c index c19f77c5..49187dab 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -356,7 +356,7 @@ static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user) for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++) { - _GLFWjoystick* js = _glfw.joysticks + jid; + js = _glfw.joysticks + jid; if (js->present) { if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0) @@ -672,11 +672,11 @@ int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode) }; // Screams of horror are appropriate at this point - int state = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES); - if (state < 0 || state > 8) - state = 8; + int stateIndex = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES); + if (stateIndex < 0 || stateIndex > 8) + stateIndex = 8; - _glfwInputJoystickHat(js, pi, states[state]); + _glfwInputJoystickHat(js, pi, states[stateIndex]); pi++; break; } From 105cf32e0b05e207d4cd5efa462887569ca2116a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 26 May 2020 23:35:40 +0200 Subject: [PATCH 240/942] Fix desktop GL header not always being suppressed If an OpenGL ES header or the glcorearb header is included before the GLFW header (with no options defined), the legacy OpenGL header will be implicitly included and the compilation will fail. This disables the default behavior if we detect any known OpenGL, OpenGL ES or extension loader inclusion guard macro. Sources: - Khronos headers - Windows SDK - MinGW - MinGW-w64 - flextGL - glad - glad2 - GLEW - Galogen - gl3w - GLXW - glbinding - Epoxy - Glatter - glLoadGen - Regal - GLee - OpenGL.framework - Debian - FreeBSD - ANGLE - SwiftShader Related to #1695. --- include/GLFW/glfw3.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e077a0c4..b239735e 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -193,7 +193,22 @@ extern "C" { #endif /*__APPLE__*/ -#elif !defined(GLFW_INCLUDE_NONE) +#elif !defined(GLFW_INCLUDE_NONE) && \ + !defined(__gl_h_) && \ + !defined(__gles1_gl_h_) && \ + !defined(__gles2_gl2_h_) && \ + !defined(__gles2_gl3_h_) && \ + !defined(__gles2_gl31_h_) && \ + !defined(__gles2_gl32_h_) && \ + !defined(__gl_glcorearb_h_) && \ + !defined(__gl2_h_) /*legacy*/ && \ + !defined(__gl3_h_) /*legacy*/ && \ + !defined(__gl31_h_) /*legacy*/ && \ + !defined(__gl32_h_) /*legacy*/ && \ + !defined(__glcorearb_h_) /*legacy*/ && \ + !defined(__GL_H__) /*non-standard*/ && \ + !defined(__gltypes_h_) /*non-standard*/ && \ + !defined(__glee_h_) /*non-standard*/ #if defined(__APPLE__) From 7486e12f88b2a9039b805356bcbe259c0fca5c2d Mon Sep 17 00:00:00 2001 From: "A. Tombs" Date: Fri, 22 May 2020 14:37:58 +0100 Subject: [PATCH 241/942] Add statement to docs for glfwTerminate It is safe to call glfwTerminate both before initialization and after termination. Closes #1698. --- include/GLFW/glfw3.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index b239735e..9893e359 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1881,6 +1881,8 @@ GLFWAPI int glfwInit(void); * call this function, as it is called by @ref glfwInit before it returns * failure. * + * This function has no effect if GLFW is not initialized. + * * @errors Possible errors include @ref GLFW_PLATFORM_ERROR. * * @remark This function may be called before @ref glfwInit. From fbf8aae44f4e37dc32747dacec86c255aad228c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 May 2020 18:07:57 +0200 Subject: [PATCH 242/942] Fix typo in header option macro docs --- docs/build.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build.dox b/docs/build.dox index cfa5b633..b7838f01 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -105,7 +105,7 @@ __GLFW_INCLUDE_ES31__ makes the GLFW header include the OpenGL ES 3.1 `GLES3/gl31.h` header instead of the regular OpenGL header. @anchor GLFW_INCLUDE_ES32 -__GLFW_INCLUDE_ES31__ makes the GLFW header include the OpenGL ES 3.2 +__GLFW_INCLUDE_ES32__ makes the GLFW header include the OpenGL ES 3.2 `GLES3/gl32.h` header instead of the regular OpenGL header. @anchor GLFW_INCLUDE_NONE From 9a87c2a4b49808d3666c7b093b77e8512fa23908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 20 May 2020 18:02:58 +0200 Subject: [PATCH 243/942] Add feature available/implemented errors This adds two new error codes: GLFW_FEATURE_UNAVAILABLE for when a GLFW feature cannot be reasonably implemented on that platform, and GLFW_FEATURE_UNIMPLEMENTED for when it can be but has not been yet. This replaces the current situation where the Wayland code emitted GLFW_PLATFORM_ERROR in both cases while the macOS code silently did nothing. If your application exits on any GLFW error, these error codes should at least be easy to filter out from that behavior. Ideally, GLFW_FEATURE_UNAVAILABLE should be rare and GLFW_FEATURE_UNIMPLEMENTED should never be emitted at all. Fixes #1692. --- README.md | 2 ++ include/GLFW/glfw3.h | 73 +++++++++++++++++++++++++++++++------------- src/cocoa_window.m | 5 ++- src/init.c | 4 +++ src/wl_monitor.c | 4 +-- src/wl_window.c | 28 ++++++++++------- 6 files changed, 81 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 761a942b..f7b16e6f 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,8 @@ information on what to include when reporting a bug. - Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427) - Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427) - Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427) + - Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692) + - Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692) - Updated the minimum required CMake version to 3.1 - Disabled tests and examples by default when built as a CMake subdirectory - Bugfix: The CMake config-file package used an absolute path and was not diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 9893e359..6db5b579 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -783,6 +783,33 @@ extern "C" { * [custom cursor](@ref cursor_custom). */ #define GLFW_CURSOR_UNAVAILABLE 0x0001000B +/*! @brief The reuqested feature is not provided by the platform. + * + * The requested feature is not provided by the platform, so GLFW is unable to + * implement it. The documentation for each function notes if it could emit + * this error. + * + * @analysis Platform or platform version limitation. The error can be ignored + * unless the feature is critical to the application. + * + * @par + * A function call that emits this error has no effect other than the error and + * updating any existing out parameters. + */ +#define GLFW_FEATURE_UNAVAILABLE 0x0001000C +/*! @brief The requested feature is not implemented for the platform. + * + * The requested feature has not yet been implemented in GLFW for this platform. + * + * @analysis An incomplete implementation of GLFW for this platform, hopefully + * fixed in a future release. The error can be ignored unless the feature is + * critical to the application. + * + * @par + * A function call that emits this error has no effect other than the error and + * updating any existing out parameters. + */ +#define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D /*! @} */ /*! @addtogroup window @@ -2871,21 +2898,21 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); * @param[in] images The images to create the icon from. This is ignored if * count is zero. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * * @pointer_lifetime The specified image data is copied before this function * returns. * - * @remark @macos The GLFW window has no icon, as it is not a document - * window, so this function does nothing. The dock icon will be the same as + * @remark @macos Regular windows do not have icons on macOS. This function + * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as * the application bundle's icon. For more information on bundles, see the * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) * in the Mac Developer Library. * * @remark @wayland There is no existing protocol to change an icon, the * window will thus inherit the one defined in the application's desktop file. - * This function always emits @ref GLFW_PLATFORM_ERROR. + * This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. * @@ -2911,12 +2938,12 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i * @param[out] ypos Where to store the y-coordinate of the upper-left corner of * the content area, or `NULL`. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * * @remark @wayland There is no way for an application to retrieve the global - * position of its windows, this function will always emit @ref - * GLFW_PLATFORM_ERROR. + * position of its windows. This function will emit @ref + * GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. * @@ -2945,12 +2972,12 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * @param[in] xpos The x-coordinate of the upper-left corner of the content area. * @param[in] ypos The y-coordinate of the upper-left corner of the content area. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * * @remark @wayland There is no way for an application to set the global - * position of its windows, this function will always emit @ref - * GLFW_PLATFORM_ERROR. + * position of its windows. This function will emit @ref + * GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. * @@ -3262,8 +3289,11 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window); * @param[in] window The window to set the opacity for. * @param[in] opacity The desired opacity of the specified window. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). + * + * @remark @wayland There is no way to set an opacity factor for a window. + * This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. * @@ -3430,11 +3460,11 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window); * * @param[in] window The window to give input focus. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland It is not possible for an application to bring its windows - * to front, this function will always emit @ref GLFW_PLATFORM_ERROR. + * @remark @wayland It is not possible for an application to set the input + * focus. This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. * @@ -4186,7 +4216,7 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); * If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE` * to enable raw (unscaled and unaccelerated) mouse motion when the cursor is * disabled, or `GLFW_FALSE` to disable it. If raw motion is not supported, - * attempting to set this will emit @ref GLFW_PLATFORM_ERROR. Call @ref + * attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref * glfwRawMouseMotionSupported to check for support. * * @param[in] window The window whose input mode to set. @@ -4196,7 +4226,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); * @param[in] value The new value of the specified input mode. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref + * GLFW_FEATURE_UNAVAILABLE (see above). * * @thread_safety This function must only be called from the main thread. * diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 7b50c753..b7a18cad 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -982,7 +982,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count, const GLFWimage* images) { - // Regular windows do not have icons + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Cocoa: Regular windows do not have icons on macOS"); } void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) @@ -1376,6 +1377,8 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) { + _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, + "Cocoa: Raw mouse motion not yet implemented"); } GLFWbool _glfwPlatformRawMouseMotionSupported(void) diff --git a/src/init.c b/src/init.c index 13baff70..d23bbfa9 100644 --- a/src/init.c +++ b/src/init.c @@ -191,6 +191,10 @@ void _glfwInputError(int code, const char* format, ...) strcpy(description, "The specified window has no context"); else if (code == GLFW_CURSOR_UNAVAILABLE) strcpy(description, "The specified cursor shape is unavailable"); + else if (code == GLFW_FEATURE_UNAVAILABLE) + strcpy(description, "The requested feature cannot be implemented for this platform"); + else if (code == GLFW_FEATURE_UNIMPLEMENTED) + strcpy(description, "The requested feature has not yet been implemented for this platform"); else strcpy(description, "ERROR: UNKNOWN GLFW ERROR"); } diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 55f62015..a6356de0 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -199,7 +199,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { - _glfwInputError(GLFW_PLATFORM_ERROR, + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Wayland: Gamma ramp access is not available"); return GLFW_FALSE; } @@ -207,7 +207,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { - _glfwInputError(GLFW_PLATFORM_ERROR, + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, "Wayland: Gamma ramp access is not available"); } diff --git a/src/wl_window.c b/src/wl_window.c index 26cb2ac1..a6d5569c 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -883,8 +883,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count, const GLFWimage* images) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Setting window icon not supported"); + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The platform does not support setting the window icon"); } void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) @@ -892,16 +892,16 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) // A Wayland client is not aware of its position, so just warn and leave it // as (0, 0) - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Window position retrieval not supported"); + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The platform does not provide the window position"); } void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) { // A Wayland client can not set its position, so just warn - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Window position setting not supported"); + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The platform does not support setting the window position"); } void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) @@ -940,6 +940,8 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, { // TODO: find out how to trigger a resize. // The actual limits are checked in the xdg_toplevel::configure handler. + _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, + "Wayland: Window aspect ratio not yet implemented"); } void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, @@ -1030,14 +1032,14 @@ void _glfwPlatformHideWindow(_GLFWwindow* window) void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) { // TODO - _glfwInputError(GLFW_PLATFORM_ERROR, + _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, "Wayland: Window attention request not implemented yet"); } void _glfwPlatformFocusWindow(_GLFWwindow* window) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Focusing a window requires user interaction"); + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The platform does not support setting the input focus"); } void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, @@ -1096,7 +1098,7 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) { // TODO - _glfwInputError(GLFW_PLATFORM_ERROR, + _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, "Wayland: Window attribute setting not implemented yet"); } @@ -1114,7 +1116,7 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) { // TODO - _glfwInputError(GLFW_PLATFORM_ERROR, + _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, "Wayland: Window attribute setting not implemented yet"); } @@ -1125,6 +1127,8 @@ float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) { + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The platform does not support setting the window opacity"); } void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) @@ -1186,6 +1190,8 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) const char* _glfwPlatformGetScancodeName(int scancode) { // TODO + _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, + "Wayland: Key names not yet implemented"); return NULL; } From 399c2a1fadbe6a1019c54f63d3839ef97a77d783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 May 2020 17:38:21 +0200 Subject: [PATCH 244/942] Clarify docs on default GL header inclusion The documentation claims that any extension loader library header included before the GLFW one will prevent the inclusion of the default OpenGL header. In reality this only worked if the loader defined the canonical desktop OpenGL __gl_h_ inclusion guard and even then relied on the OpenGL header to detect this. This is the companion to 105cf32e0b05e207d4cd5efa462887569ca2116a, which added the preprocessor logic to check for many known OpenGL and OpenGL ES inclusion guards and not even attempt to include the default header if any are present. Some clarification of the language around header inclusion has also been attempted, including making GLFW_INCLUDE_NONE more prominent. Fixes #1695. --- README.md | 2 ++ docs/build.dox | 41 ++++++++++++++++++++++------------------- docs/quick.dox | 47 +++++++++++++++++++++++------------------------ 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index f7b16e6f..387f14c1 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,8 @@ information on what to include when reporting a bug. - 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) + - Bugfix: Some extension loader headers did not prevent default OpenGL header + inclusion (#1695) - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - [Win32] Added a version info resource to the GLFW DLL diff --git a/docs/build.dox b/docs/build.dox index b7838f01..aa06b0f4 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -25,39 +25,41 @@ GLFW. #include @endcode -This header declares the GLFW API and by default also includes the OpenGL header -from your development environment. See below for how to control this. +This header defines all the constants and declares all the types and function +prototypes of the GLFW API. By default it also includes the OpenGL header from +your development environment. See [option macros](@ref build_macros) below for +how to select OpenGL ES headers and more. The GLFW header also defines any platform-specific macros needed by your OpenGL -header, so it can be included without needing any window system headers. +header, so that it can be included without needing any window system headers. -For example, under Windows you are normally required to include `windows.h` -before the OpenGL header, which would bring in the whole Win32 API. The GLFW -header duplicates the small number of macros needed. - -It does this only when needed, so if `windows.h` _is_ included, the GLFW header -does not try to redefine those symbols. The reverse is not true, i.e. -`windows.h` cannot cope if any of its symbols have already been defined. +It does this only when needed, so if window system headers are included, the +GLFW header does not try to redefine those symbols. The reverse is not true, +i.e. `windows.h` cannot cope if any Win32 symbols have already been defined. In other words: - - Do _not_ include the OpenGL headers yourself, as GLFW does this for you - - Do _not_ include `windows.h` or other platform-specific headers unless you - plan on using those APIs directly - - If you _do_ need to include such headers, do it _before_ including - the GLFW header and it will handle this + - Use the GLFW header to include OpenGL or OpenGL ES headers portably + - Do not include window system headers unless you will use those APIs directly + - If you do need such headers, include them before the GLFW header If you are using an OpenGL extension loading library such as [glad](https://github.com/Dav1dde/glad), the extension loader header should -be included _before_ the GLFW one. +be included before the GLFW one. GLFW attempts to detect any OpenGL or OpenGL +ES header or extension loader header included before it and will then disable +the inclusion of the default OpenGL header. Most extension loaders also define +macros that disable similar headers below it. @code #include #include @endcode -Alternatively the @ref GLFW_INCLUDE_NONE macro (described below) can be used to -prevent the GLFW header from including the OpenGL header. +Both of these mechanisms depend on the extension loader header defining a known +macro. If yours doesn't or you don't know which one your users will pick, the +@ref GLFW_INCLUDE_NONE macro will explicitly to prevent the GLFW header from +including the OpenGL header. This will also allow you to include the two +headers in any order. @code #define GLFW_INCLUDE_NONE @@ -113,7 +115,8 @@ __GLFW_INCLUDE_NONE__ makes the GLFW header not include any OpenGL or OpenGL ES API header. This is useful in combination with an extension loading library. If none of the above inclusion macros are defined, the standard OpenGL `GL/gl.h` -header (`OpenGL/gl.h` on macOS) is included. +header (`OpenGL/gl.h` on macOS) is included, unless GLFW detects the inclusion +guards of any OpenGL, OpenGL ES or extension loader header it knows about. The following macros control the inclusion of additional API headers. Any number of these may be defined simultaneously, and/or together with one of the diff --git a/docs/quick.dox b/docs/quick.dox index f6db339f..c3f47aa1 100644 --- a/docs/quick.dox +++ b/docs/quick.dox @@ -18,43 +18,42 @@ behave differently in GLFW 3. @subsection quick_include Including the GLFW header -In the source files of your application where you use OpenGL or GLFW, you need -to include the GLFW 3 header file. +In the source files of your application where you use GLFW, you need to include +its header file. @code #include @endcode -This defines all the constants, types and function prototypes of the GLFW API. -It also includes the OpenGL header from your development environment and -defines all the constants and types necessary for it to work on your platform -without including any platform-specific headers. +This header provides all the constants, types and function prototypes of the +GLFW API. -In other words: +By default it also includes the OpenGL header from your development environment. +On some platforms this header only supports older versions of OpenGL. The most +extreme case is Windows, where it typically only supports OpenGL 1.2. -- Do _not_ include the OpenGL header yourself, as GLFW does this for you in - a platform-independent way -- Do _not_ include `windows.h` or other platform-specific headers unless - you plan on using those APIs yourself -- If you _do_ need to include such headers, include them _before_ the GLFW - header and it will detect this - -On some platforms supported by GLFW the OpenGL header and link library only -expose older versions of OpenGL. The most extreme case is Windows, which only -exposes OpenGL 1.2. The easiest way to work around this is to use an -[extension loader library](@ref context_glext_auto). - -If you are using such a library then you should include its header _before_ the -GLFW header. This lets it replace the OpenGL header included by GLFW without -conflicts. This example uses -[glad2](https://github.com/Dav1dde/glad), but the same rule applies to all such -libraries. +Most programs will instead use an +[extension loader library](@ref context_glext_auto) and include its header. +This example uses files generated by [glad](https://gen.glad.sh/). The GLFW +header can detect most such headers if they are included first and will then not +include the one from your development environment. @code #include #include @endcode +To make sure there will be no header conflicts, you can define @ref +GLFW_INCLUDE_NONE before the GLFW header to explicitly disable inclusion of the +development environment header. This also allows the two headers to be included +in any order. + +@code +#define GLFW_INCLUDE_NONE +#include +#include +@endcode + @subsection quick_init_term Initializing and terminating GLFW From c72da994bac2a21ef07f891a44ab49570d650dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 2 Jun 2020 19:54:30 +0200 Subject: [PATCH 245/942] Wayland: Fix repeated keys reported to NULL window This fixes a race between the key repeat logic and the surface leave event handler, which could result in repeated keys being reported with a window of NULL. Fixes #1704. --- README.md | 2 ++ src/wl_window.c | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 387f14c1..4eccb828 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,7 @@ information on what to include when reporting a bug. - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled + - [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704) - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [NSGL] Removed enforcement of forward-compatible flag for core contexts - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer @@ -398,6 +399,7 @@ skills. - Torsten Walluhn - Patrick Walton - Xo Wang + - Waris - Jay Weisskopf - Frank Wille - Ryogo Yoshimura diff --git a/src/wl_window.c b/src/wl_window.c index a6d5569c..f5d314f3 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -749,10 +749,17 @@ static void handleEvents(int timeout) if (read_ret != 8) return; - for (i = 0; i < repeats; ++i) - _glfwInputKey(_glfw.wl.keyboardFocus, _glfw.wl.keyboardLastKey, - _glfw.wl.keyboardLastScancode, GLFW_REPEAT, - _glfw.wl.xkb.modifiers); + if (_glfw.wl.keyboardFocus) + { + for (i = 0; i < repeats; ++i) + { + _glfwInputKey(_glfw.wl.keyboardFocus, + _glfw.wl.keyboardLastKey, + _glfw.wl.keyboardLastScancode, + GLFW_REPEAT, + _glfw.wl.xkb.modifiers); + } + } } if (fds[2].revents & POLLIN) From e0c77f71f90e3bb8495c5c88fb0fb054d71cf7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 May 2020 17:16:26 +0200 Subject: [PATCH 246/942] Null: Make platform more conformant This makes the null platform behave more like an actual stub. More queryable state is tracked and there is even a fake monitor with one whole fake video mode. --- src/null_init.c | 5 + src/null_monitor.c | 82 +++++++++- src/null_platform.h | 40 ++++- src/null_window.c | 365 +++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 462 insertions(+), 30 deletions(-) diff --git a/src/null_init.c b/src/null_init.c index 20c76dc5..57aafd5d 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -29,6 +29,8 @@ #include "internal.h" +#include + ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// @@ -37,11 +39,14 @@ int _glfwPlatformInit(void) { _glfwInitTimerPOSIX(); + _glfwPollMonitorsNull(); + return GLFW_TRUE; } void _glfwPlatformTerminate(void) { + free(_glfw.null.clipboardString); _glfwTerminateOSMesa(); } diff --git a/src/null_monitor.c b/src/null_monitor.c index 0a7fe064..7271e810 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -29,6 +29,37 @@ #include "internal.h" +#include +#include +#include + +// The the sole (fake) video mode of our (sole) fake monitor +// +static GLFWvidmode getVideoMode(void) +{ + GLFWvidmode mode; + mode.width = 1920; + mode.height = 1080; + mode.redBits = 8; + mode.greenBits = 8; + mode.blueBits = 8; + mode.refreshRate = 60; + return mode; +} + +////////////////////////////////////////////////////////////////////////// +////// GLFW internal API ////// +////////////////////////////////////////////////////////////////////////// + +void _glfwPollMonitorsNull(void) +{ + const float dpi = 141.f; + const GLFWvidmode mode = getVideoMode(); + _GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0", + (int) (mode.width * 25.4f / dpi), + (int) (mode.height * 25.4f / dpi)); + _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST); +} ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// @@ -36,6 +67,7 @@ void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor) { + _glfwFreeGammaArrays(&monitor->null.ramp); } void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) @@ -55,23 +87,69 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height) { + const GLFWvidmode mode = getVideoMode(); + + if (xpos) + *xpos = 10; + if (ypos) + ypos = 0; + if (width) + *width = mode.width; + if (height) + *height = mode.height - 10; } GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) { - return NULL; + GLFWvidmode* mode = calloc(1, sizeof(GLFWvidmode)); + *mode = getVideoMode(); + *found = 1; + return mode; } void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) { + *mode = getVideoMode(); } GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { - return GLFW_FALSE; + if (!monitor->null.ramp.size) + { + _glfwAllocGammaArrays(&monitor->null.ramp, 256); + + for (unsigned int i = 0; i < monitor->null.ramp.size; i++) + { + const float gamma = 2.2f; + float value; + value = i / (float) (monitor->null.ramp.size - 1); + value = powf(value, 1.f / gamma) * 65535.f + 0.5f; + value = _glfw_fminf(value, 65535.f); + + monitor->null.ramp.red[i] = (unsigned short) value; + monitor->null.ramp.green[i] = (unsigned short) value; + monitor->null.ramp.blue[i] = (unsigned short) value; + } + } + + _glfwAllocGammaArrays(ramp, monitor->null.ramp.size); + memcpy(ramp->red, monitor->null.ramp.red, sizeof(short) * ramp->size); + memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size); + memcpy(ramp->blue, monitor->null.ramp.blue, sizeof(short) * ramp->size); + return GLFW_TRUE; } void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { + if (monitor->null.ramp.size != ramp->size) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Null: Gamma ramp size must match current ramp size"); + return; + } + + memcpy(monitor->null.ramp.red, ramp->red, sizeof(short) * ramp->size); + memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size); + memcpy(monitor->null.ramp.blue, ramp->blue, sizeof(short) * ramp->size); } diff --git a/src/null_platform.h b/src/null_platform.h index fdea9906..c0995be3 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -27,12 +27,12 @@ #include -#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null +#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null +#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null +#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNull null #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; } @@ -56,7 +56,37 @@ // typedef struct _GLFWwindowNull { - int width; - int height; + int xpos; + int ypos; + int width; + int height; + char* title; + GLFWbool visible; + GLFWbool iconified; + GLFWbool maximized; + GLFWbool resizable; + GLFWbool decorated; + GLFWbool floating; + GLFWbool transparent; + float opacity; } _GLFWwindowNull; +// Null-specific per-monitor data +// +typedef struct _GLFWmonitorNull +{ + GLFWgammaramp ramp; +} _GLFWmonitorNull; + +// Null-specific global data +// +typedef struct _GLFWlibraryNull +{ + int xcursor; + int ycursor; + char* clipboardString; + _GLFWwindow* focusedWindow; +} _GLFWlibraryNull; + +void _glfwPollMonitorsNull(void); + diff --git a/src/null_window.c b/src/null_window.c index 936400d3..ba85571b 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -29,12 +29,71 @@ #include "internal.h" +#include + +static void applySizeLimits(_GLFWwindow* window, int* width, int* height) +{ + if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE) + { + const float ratio = (float) window->numer / (float) window->denom; + *height = (int) (*width / ratio); + } + + if (window->minwidth != GLFW_DONT_CARE && *width < window->minwidth) + *width = window->minwidth; + else if (window->maxwidth != GLFW_DONT_CARE && *width > window->maxwidth) + *width = window->maxwidth; + + if (window->minheight != GLFW_DONT_CARE && *height < window->minheight) + *height = window->minheight; + else if (window->maxheight != GLFW_DONT_CARE && *height > window->maxheight) + *height = window->maxheight; +} + +static void fitToMonitor(_GLFWwindow* window) +{ + GLFWvidmode mode; + _glfwPlatformGetVideoMode(window->monitor, &mode); + _glfwPlatformGetMonitorPos(window->monitor, + &window->null.xpos, + &window->null.ypos); + window->null.width = mode.width; + window->null.height = mode.height; +} + +static void acquireMonitor(_GLFWwindow* window) +{ + _glfwInputMonitorWindow(window->monitor, window); +} + +static void releaseMonitor(_GLFWwindow* window) +{ + if (window->monitor->window != window) + return; + + _glfwInputMonitorWindow(window->monitor, NULL); +} static int createNativeWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig) + const _GLFWwndconfig* wndconfig, + const _GLFWfbconfig* fbconfig) { - window->null.width = wndconfig->width; - window->null.height = wndconfig->height; + if (window->monitor) + fitToMonitor(window); + else + { + window->null.xpos = 17; + window->null.ypos = 17; + window->null.width = wndconfig->width; + window->null.height = wndconfig->height; + } + + window->null.visible = wndconfig->visible; + window->null.decorated = wndconfig->decorated; + window->null.maximized = wndconfig->maximized; + window->null.floating = wndconfig->floating; + window->null.transparent = fbconfig->transparent; + window->null.opacity = 1.f; return GLFW_TRUE; } @@ -49,7 +108,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) { - if (!createNativeWindow(window, wndconfig)) + if (!createNativeWindow(window, wndconfig, fbconfig)) return GLFW_FALSE; if (ctxconfig->client != GLFW_NO_API) @@ -69,11 +128,24 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, } } + if (window->monitor) + { + _glfwPlatformShowWindow(window); + _glfwPlatformFocusWindow(window); + acquireMonitor(window); + } + return GLFW_TRUE; } void _glfwPlatformDestroyWindow(_GLFWwindow* window) { + if (window->monitor) + releaseMonitor(window); + + if (_glfw.null.focusedWindow == window) + _glfw.null.focusedWindow = NULL; + if (window->context.destroy) window->context.destroy(window); } @@ -93,14 +165,54 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, int width, int height, int refreshRate) { + if (window->monitor == monitor) + { + if (!monitor) + { + _glfwPlatformSetWindowPos(window, xpos, ypos); + _glfwPlatformSetWindowSize(window, width, height); + } + + return; + } + + if (window->monitor) + releaseMonitor(window); + + _glfwInputWindowMonitor(window, monitor); + + if (window->monitor) + { + window->null.visible = GLFW_TRUE; + acquireMonitor(window); + fitToMonitor(window); + } + else + { + _glfwPlatformSetWindowPos(window, xpos, ypos); + _glfwPlatformSetWindowSize(window, width, height); + } } void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos) { + if (xpos) + *xpos = window->null.xpos; + if (ypos) + *ypos = window->null.ypos; } void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos) { + if (window->monitor) + return; + + if (window->null.xpos != xpos || window->null.ypos != ypos) + { + window->null.xpos = xpos; + window->null.ypos = ypos; + _glfwInputWindowPos(window, xpos, ypos); + } } void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) @@ -113,18 +225,34 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height) void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) { - window->null.width = width; - window->null.height = height; + if (window->monitor) + return; + + if (window->null.width != width || window->null.height != height) + { + window->null.width = width; + window->null.height = height; + _glfwInputWindowSize(window, width, height); + _glfwInputFramebufferSize(window, width, height); + } } void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight) { + int width = window->null.width; + int height = window->null.height; + applySizeLimits(window, &width, &height); + _glfwPlatformSetWindowSize(window, width, height); } void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d) { + int width = window->null.width; + int height = window->null.height; + applySizeLimits(window, &width, &height); + _glfwPlatformSetWindowSize(window, width, height); } void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height) @@ -139,6 +267,13 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top, int* right, int* bottom) { + if (window->null.decorated && !window->monitor) + { + *left = 1; + *top = 10; + *right = 1; + *bottom = 1; + } } void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, @@ -152,50 +287,89 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, void _glfwPlatformIconifyWindow(_GLFWwindow* window) { + if (_glfw.null.focusedWindow == window) + { + _glfw.null.focusedWindow = NULL; + _glfwInputWindowFocus(window, GLFW_FALSE); + } + + if (!window->null.iconified) + { + window->null.iconified = GLFW_TRUE; + _glfwInputWindowIconify(window, GLFW_TRUE); + + if (window->monitor) + releaseMonitor(window); + } } void _glfwPlatformRestoreWindow(_GLFWwindow* window) { + if (window->null.iconified) + { + window->null.iconified = GLFW_FALSE; + _glfwInputWindowIconify(window, GLFW_FALSE); + + if (window->monitor) + acquireMonitor(window); + } + else if (window->null.maximized) + { + window->null.maximized = GLFW_FALSE; + _glfwInputWindowMaximize(window, GLFW_FALSE); + } } void _glfwPlatformMaximizeWindow(_GLFWwindow* window) { + if (!window->null.maximized) + { + window->null.maximized = GLFW_TRUE; + _glfwInputWindowMaximize(window, GLFW_TRUE); + } } int _glfwPlatformWindowMaximized(_GLFWwindow* window) { - return GLFW_FALSE; + return window->null.maximized; } int _glfwPlatformWindowHovered(_GLFWwindow* window) { - return GLFW_FALSE; + return _glfw.null.xcursor >= window->null.xpos && + _glfw.null.ycursor >= window->null.ypos && + _glfw.null.xcursor <= window->null.xpos + window->null.width - 1 && + _glfw.null.ycursor <= window->null.ypos + window->null.height - 1; } int _glfwPlatformFramebufferTransparent(_GLFWwindow* window) { - return GLFW_FALSE; + return window->null.transparent; } void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) { + window->null.resizable = enabled; } void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) { + window->null.decorated = enabled; } void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) { + window->null.floating = enabled; } float _glfwPlatformGetWindowOpacity(_GLFWwindow* window) { - return 1.f; + return window->null.opacity; } void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) { + window->null.opacity = opacity; } void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) @@ -204,43 +378,63 @@ void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled) GLFWbool _glfwPlatformRawMouseMotionSupported(void) { - return GLFW_FALSE; + return GLFW_TRUE; } void _glfwPlatformShowWindow(_GLFWwindow* window) { + window->null.visible = GLFW_TRUE; } - void _glfwPlatformRequestWindowAttention(_GLFWwindow* window) { } -void _glfwPlatformUnhideWindow(_GLFWwindow* window) -{ -} - void _glfwPlatformHideWindow(_GLFWwindow* window) { + if (_glfw.null.focusedWindow == window) + { + _glfw.null.focusedWindow = NULL; + _glfwInputWindowFocus(window, GLFW_FALSE); + } + + window->null.visible = GLFW_FALSE; } void _glfwPlatformFocusWindow(_GLFWwindow* window) { + if (_glfw.null.focusedWindow == window) + return; + + if (!window->null.visible) + return; + + _GLFWwindow* previous = _glfw.null.focusedWindow; + _glfw.null.focusedWindow = window; + + if (previous) + { + _glfwInputWindowFocus(previous, GLFW_FALSE); + if (previous->monitor && previous->autoIconify) + _glfwPlatformIconifyWindow(previous); + } + + _glfwInputWindowFocus(window, GLFW_TRUE); } int _glfwPlatformWindowFocused(_GLFWwindow* window) { - return GLFW_FALSE; + return _glfw.null.focusedWindow == window; } int _glfwPlatformWindowIconified(_GLFWwindow* window) { - return GLFW_FALSE; + return window->null.iconified; } int _glfwPlatformWindowVisible(_GLFWwindow* window) { - return GLFW_FALSE; + return window->null.visible; } void _glfwPlatformPollEvents(void) @@ -261,10 +455,16 @@ void _glfwPlatformPostEmptyEvent(void) void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos) { + if (xpos) + *xpos = _glfw.null.xcursor - window->null.xpos; + if (ypos) + *ypos = _glfw.null.ycursor - window->null.ypos; } void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) { + _glfw.null.xcursor = window->null.xpos + (int) x; + _glfw.null.ycursor = window->null.ypos + (int) y; } void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) @@ -293,21 +493,140 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) void _glfwPlatformSetClipboardString(const char* string) { + char* copy = _glfw_strdup(string); + free(_glfw.null.clipboardString); + _glfw.null.clipboardString = copy; } const char* _glfwPlatformGetClipboardString(void) { - return NULL; + return _glfw.null.clipboardString; } const char* _glfwPlatformGetScancodeName(int scancode) { - return ""; + switch (scancode) + { + case GLFW_KEY_APOSTROPHE: + return "'"; + case GLFW_KEY_COMMA: + return ","; + case GLFW_KEY_MINUS: + case GLFW_KEY_KP_SUBTRACT: + return "-"; + case GLFW_KEY_PERIOD: + case GLFW_KEY_KP_DECIMAL: + return "."; + case GLFW_KEY_SLASH: + case GLFW_KEY_KP_DIVIDE: + return "/"; + case GLFW_KEY_SEMICOLON: + return ";"; + case GLFW_KEY_EQUAL: + case GLFW_KEY_KP_EQUAL: + return "="; + case GLFW_KEY_LEFT_BRACKET: + return "["; + case GLFW_KEY_RIGHT_BRACKET: + return "]"; + case GLFW_KEY_KP_MULTIPLY: + return "*"; + case GLFW_KEY_KP_ADD: + return "+"; + case GLFW_KEY_BACKSLASH: + case GLFW_KEY_WORLD_1: + case GLFW_KEY_WORLD_2: + return "\\"; + case GLFW_KEY_0: + case GLFW_KEY_KP_0: + return "0"; + case GLFW_KEY_1: + case GLFW_KEY_KP_1: + return "1"; + case GLFW_KEY_2: + case GLFW_KEY_KP_2: + return "2"; + case GLFW_KEY_3: + case GLFW_KEY_KP_3: + return "3"; + case GLFW_KEY_4: + case GLFW_KEY_KP_4: + return "4"; + case GLFW_KEY_5: + case GLFW_KEY_KP_5: + return "5"; + case GLFW_KEY_6: + case GLFW_KEY_KP_6: + return "6"; + case GLFW_KEY_7: + case GLFW_KEY_KP_7: + return "7"; + case GLFW_KEY_8: + case GLFW_KEY_KP_8: + return "8"; + case GLFW_KEY_9: + case GLFW_KEY_KP_9: + return "9"; + case GLFW_KEY_A: + return "a"; + case GLFW_KEY_B: + return "b"; + case GLFW_KEY_C: + return "c"; + case GLFW_KEY_D: + return "d"; + case GLFW_KEY_E: + return "e"; + case GLFW_KEY_F: + return "f"; + case GLFW_KEY_G: + return "g"; + case GLFW_KEY_H: + return "h"; + case GLFW_KEY_I: + return "i"; + case GLFW_KEY_J: + return "j"; + case GLFW_KEY_K: + return "k"; + case GLFW_KEY_L: + return "l"; + case GLFW_KEY_M: + return "m"; + case GLFW_KEY_N: + return "n"; + case GLFW_KEY_O: + return "o"; + case GLFW_KEY_P: + return "p"; + case GLFW_KEY_Q: + return "q"; + case GLFW_KEY_R: + return "r"; + case GLFW_KEY_S: + return "s"; + case GLFW_KEY_T: + return "t"; + case GLFW_KEY_U: + return "u"; + case GLFW_KEY_V: + return "v"; + case GLFW_KEY_W: + return "w"; + case GLFW_KEY_X: + return "x"; + case GLFW_KEY_Y: + return "y"; + case GLFW_KEY_Z: + return "z"; + } + + return NULL; } int _glfwPlatformGetKeyScancode(int key) { - return -1; + return key; } void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) @@ -327,6 +646,6 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, VkSurfaceKHR* surface) { // This seems like the most appropriate error to return here - return VK_ERROR_INITIALIZATION_FAILED; + return VK_ERROR_EXTENSION_NOT_PRESENT; } From 69ff0b8ee08d9696c9322d3bf0222ca119cca9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 5 Jun 2020 14:19:34 +0200 Subject: [PATCH 247/942] Refresh Doxygen file with version 1.8.18 --- docs/Doxyfile.in | 2536 +++++++++++++++++++++++++++++----------------- 1 file changed, 1603 insertions(+), 933 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 825356d9..c3682222 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1,110 +1,137 @@ -# Doxyfile 1.8.3.1 +# Doxyfile 1.8.18 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # -# All text after a hash (#) is considered a comment and will be ignored. +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. # The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. PROJECT_NAME = "GLFW" -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. 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 -# a quick idea about the purpose of the project. Keep the description short. +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "A multi-platform library for OpenGL, window and input" -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. PROJECT_LOGO = -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. OUTPUT_DIRECTORY = "@GLFW_BINARY_DIR@/docs" -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. CREATE_SUBDIRS = NO +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. +# The default value is: YES. REPEAT_BRIEF = NO -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# doxygen will generate a detailed section even if there is only a brief # description. +# The default value is: NO. ALWAYS_DETAILED_SEC = YES @@ -112,88 +139,117 @@ ALWAYS_DETAILED_SEC = YES # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. +# The default value is: NO. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. FULL_PATH_NAMES = NO -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. Note that you specify absolute paths here, but also -# relative paths, which will be relative from the directory where doxygen is -# started. +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. STRIP_FROM_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. JAVADOC_AUTOBRIEF = NO -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. MULTILINE_CPP_IS_BRIEF = NO -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. TAB_SIZE = 8 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) ALIASES = "thread_safety=@par Thread safety^^" \ "pointer_lifetime=@par Pointer lifetime^^" \ @@ -208,146 +264,189 @@ ALIASES = "thread_safety=@par Thread safety^^" \ "macos=__macOS:__" \ "linux=__Linux:__" -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. OPTIMIZE_OUTPUT_FOR_C = YES -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. OPTIMIZE_OUTPUT_VHDL = NO +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. EXTENSION_MAPPING = -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. MARKDOWN_SUPPORT = YES -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by putting a % sign in front of the word or +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. +# The default value is: NO. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. +# The default value is: NO. CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES (the -# default) will make doxygen replace the get and set methods by a property in -# the documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. IDL_PROPERTY_SUPPORT = NO # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first +# tag is set to YES then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. +# The default value is: NO. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. SUBGROUPING = YES -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. INLINE_GROUPED_CLASSES = NO -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. INLINE_SIMPLE_STRUCTS = NO -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. TYPEDEF_HIDES_STRUCT = NO -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. LOOKUP_CACHE_SIZE = 0 @@ -355,343 +454,415 @@ LOOKUP_CACHE_SIZE = 0 # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. EXTRACT_ALL = YES -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. EXTRACT_PRIVATE = NO -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. +# The default value is: NO. EXTRACT_PACKAGE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the # documentation. +# The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. +# (including Cygwin) ands Mac users are advised to set this option to NO. +# The default value is: system dependent. CASE_SENSE_NAMES = YES -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. SHOW_INCLUDE_FILES = NO -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. FORCE_LOCAL_INCLUDES = NO -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. SORT_MEMBER_DOCS = NO -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. SORT_BRIEF_DOCS = NO -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. SORT_MEMBERS_CTORS_1ST = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. SORT_GROUP_NAMES = YES -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. SORT_BY_SCOPE_NAME = NO -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. STRICT_PROTO_MATCHING = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if section-label ... \endif -# and \cond section-label ... \endcond blocks. +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the # list will mention the files that were used to generate the documentation. +# The default value is: YES. SHOW_USED_FILES = YES -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. SHOW_FILES = YES -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. SHOW_NAMESPACES = NO # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. LAYOUT_FILE = "@GLFW_SOURCE_DIR@/docs/DoxygenLayout.xml" -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. Do not use -# file names with spaces, bibtex cannot handle them. +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. CITE_BIB_FILES = #--------------------------------------------------------------------------- -# configuration options related to warning and progress messages +# Configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. QUIET = YES # The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. WARN_IF_DOC_ERROR = YES -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. +# The default value is: NO. WARN_NO_PARAMDOC = YES -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). WARN_LOGFILE = "@GLFW_BINARY_DIR@/docs/warnings.txt" #--------------------------------------------------------------------------- -# configuration options related to the input files +# Configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. 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 -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: https://www.gnu.org/software/libiconv/) for the list of +# possible encodings. +# The default value is: UTF-8. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.doc (to be provided as doxygen C comment), *.txt (to be provided as doxygen +# C comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. FILE_PATTERNS = *.h *.dox -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. +# # Note that relative paths are relative to the directory from which doxygen is # run. @@ -700,14 +871,16 @@ EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. +# The default value is: NO. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* EXCLUDE_PATTERNS = @@ -716,807 +889,1187 @@ EXCLUDE_PATTERNS = # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* EXCLUDE_SYMBOLS = APIENTRY GLFWAPI -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). EXAMPLE_PATH = "@GLFW_SOURCE_DIR@/examples" # If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. FILTER_SOURCE_PATTERNS = -# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page (index.html). -# This can be useful if you have a project on for instance GitHub and want reuse -# the introduction page also for the doxygen output. +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- -# configuration options related to source browsing +# Configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C, C++ and Fortran comments will always remain visible. +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. REFERENCED_BY_RELATION = NO -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. REFERENCES_RELATION = NO -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index +# Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. ALPHABETICAL_INDEX = YES -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = glfw GLFW_ #--------------------------------------------------------------------------- -# configuration options related to the HTML output +# Configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_HEADER = "@GLFW_SOURCE_DIR@/docs/header.html" -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_FOOTER = "@GLFW_SOURCE_DIR@/docs/footer.html" -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If left blank doxygen will -# generate a default style sheet. Note that it is recommended to use -# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this -# tag will in the future become obsolete. +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_STYLESHEET = -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional -# user-defined cascading style sheet that is included after the standard -# style sheets created by doxygen. Using this option one can overrule -# certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more -# robust against future updates. Doxygen will copy the style sheet file to -# the output directory. +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_STYLESHEET = "@GLFW_SOURCE_DIR@/docs/extra.css" # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_EXTRA_FILES = "@GLFW_SOURCE_DIR@/docs/spaces.svg" -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_HUE = 220 -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_SAT = 100 -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_TIMESTAMP = YES +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_DYNAMIC_SECTIONS = NO -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries -# and will result in a full expanded tree by default. +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_INDEX_NUM_ENTRIES = 100 -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: https://developer.apple.com/xcode/), introduced with OSX +# 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_DOCSET = NO -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_FEEDNAME = "Doxygen generated docs" -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_BUNDLE_ID = org.doxygen.Project -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely -# identify the documentation publisher. This should be a reverse domain-name -# style string, e.g. com.mycompany.MyDocSet.documentation. +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_ID = org.doxygen.Publisher -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. DOCSET_PUBLISHER_NAME = Publisher -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_HTMLHELP = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be # written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. GENERATE_CHI = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. CHM_INDEX_ENCODING = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_QHP = NO -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. QCH_FILE = -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_NAMESPACE = org.doxygen.Project -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_VIRTUAL_FOLDER = doc -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_ECLIPSEHELP = NO -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. ECLIPSE_DOC_ID = org.doxygen.Project -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. ENUM_VALUES_PER_LINE = 4 -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. TREEVIEW_WIDTH = 300 -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. EXT_LINKS_IN_WINDOW = NO -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png The default and svg Looks nicer but requires the +# pdf2svg tool. +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_FONTSIZE = 10 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. FORMULA_TRANSPARENT = YES -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for -# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and -# SVG. The default value is HTML-CSS, which is slower, but has the best -# compatibility. +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_FORMAT = HTML-CSS -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. -# However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. +# This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_RELPATH = https://cdn.jsdelivr.net/npm/mathjax@2 -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /