From b4c3ef9d0fdf46845f3e81e5d989dab06e71e6c1 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sun, 24 Dec 2023 12:23:23 +0000 Subject: [PATCH 001/137] Clarify documentation for contributing Added location of credits, news and guides. --- docs/CONTRIBUTING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 050c1bed..033c7800 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -327,7 +327,7 @@ a thousand line one, if that is the appropriate size for the fix. In addition to the code, a complete bug fix includes: - Change log entry in `README.md`, describing the incorrect behavior -- Credits entries for all authors of the bug fix +- Credits entries in `CONTRIBUTORS.md` for all authors of the bug fix Bug fixes will not be rejected because they don't include all the above parts, but please keep in mind that maintainer time is finite and that there are many @@ -358,11 +358,11 @@ feature. In addition to the code, a complete feature includes: - Change log entry in `README.md`, listing all new symbols -- News page entry, briefly describing the feature -- Guide documentation, with minimal examples, in the relevant guide +- News page entry in `docs/news.dox`, briefly describing the feature +- Guide documentation, with minimal examples, in the relevant guide in the `docs` folder - Reference documentation, with all applicable tags - Cross-references and mentions in appropriate places -- Credits entries for all authors of the feature +- Credits entries in `CONTRIBUTORS.md` for all authors of the feature If the feature requires platform-specific code, at minimum stubs must be added for the new platform function to all supported and experimental platforms. From ab09dc8fb17ab08a6b318417b84896801568c002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Dec 2023 15:27:53 +0100 Subject: [PATCH 002/137] Add credit I lost track of the existing PR #2245 when fixing #2161 with 5e4496cb420df4d93b4a31805b9fef443433f73b. Closes #2245 --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 75533ec3..6741d82f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -131,6 +131,7 @@ video tutorials. - lo-v-ol - Eyal Lotem - Aaron Loucks + - Ned Loynd - Luflosi - lukect - Tristam MacDonald From 9f6da7e7c64572436fcd56022f4147270f47deef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 10 Jan 2024 00:47:18 +0100 Subject: [PATCH 003/137] Win32: Fix some of the errors for Null-only on VS This workaround is needed whenever windows.h is included after glfw3.h. --- src/win32_thread.h | 5 +++++ src/win32_time.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/win32_thread.h b/src/win32_thread.h index 4b5a696f..dd5948f0 100644 --- a/src/win32_thread.h +++ b/src/win32_thread.h @@ -25,6 +25,11 @@ // //======================================================================== +// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for +// example to allow applications to correctly declare a GL_KHR_debug callback) +// but windows.h assumes no one will define APIENTRY before it does +#undef APIENTRY + #include #define GLFW_WIN32_TLS_STATE _GLFWtlsWin32 win32; diff --git a/src/win32_time.h b/src/win32_time.h index da5afa41..ef57a5a6 100644 --- a/src/win32_time.h +++ b/src/win32_time.h @@ -25,6 +25,11 @@ // //======================================================================== +// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for +// example to allow applications to correctly declare a GL_KHR_debug callback) +// but windows.h assumes no one will define APIENTRY before it does +#undef APIENTRY + #include #define GLFW_WIN32_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32; From 40aa77a1607a6847f88cd9abc96f8fe4da3943a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Nov 2023 19:02:38 +0100 Subject: [PATCH 004/137] Remove superfluous CMake flag in GH build workflow The source directory already defaults to the current directory. --- .github/workflows/build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c7b30df8..28c2d18d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,12 +23,12 @@ jobs: sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev - name: Configure static library - run: cmake -S . -B build-static + run: cmake -B build-static - name: Build static library run: cmake --build build-static --parallel - name: Configure shared library - run: cmake -S . -B build-shared -D BUILD_SHARED_LIBS=ON + run: cmake -B build-shared -D BUILD_SHARED_LIBS=ON - name: Build shared library run: cmake --build build-shared --parallel @@ -46,12 +46,12 @@ jobs: sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev wayland-protocols libwayland-dev libxkbcommon-dev - name: Configure static library - run: cmake -S . -B build-static -D GLFW_BUILD_WAYLAND=ON + run: cmake -B build-static -D GLFW_BUILD_WAYLAND=ON - name: Build static library run: cmake --build build-static --parallel - name: Configure shared library - run: cmake -S . -B build-shared -D GLFW_BUILD_WAYLAND=ON -D BUILD_SHARED_LIBS=ON + run: cmake -B build-shared -D GLFW_BUILD_WAYLAND=ON -D BUILD_SHARED_LIBS=ON - name: Build shared library run: cmake --build build-shared --parallel @@ -65,12 +65,12 @@ jobs: - uses: actions/checkout@v3 - name: Configure static library - run: cmake -S . -B build-static + run: cmake -B build-static - name: Build static library run: cmake --build build-static --parallel - name: Configure shared library - run: cmake -S . -B build-shared -D BUILD_SHARED_LIBS=ON + run: cmake -B build-shared -D BUILD_SHARED_LIBS=ON - name: Build shared library run: cmake --build build-shared --parallel @@ -83,12 +83,12 @@ jobs: - uses: actions/checkout@v3 - name: Configure static library - run: cmake -S . -B build-static -G "Visual Studio 17 2022" + run: cmake -B build-static -G "Visual Studio 17 2022" - name: Build static library run: cmake --build build-static --parallel - name: Configure shared library - run: cmake -S . -B build-shared -G "Visual Studio 17 2022" -D BUILD_SHARED_LIBS=ON + run: cmake -B build-shared -G "Visual Studio 17 2022" -D BUILD_SHARED_LIBS=ON - name: Build shared library run: cmake --build build-shared --parallel From 6b39ab00748ca927456d998293fa967f2b86cf9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Nov 2023 19:54:38 +0100 Subject: [PATCH 005/137] Improve coverage of GH build workflow This adds Null-only and Wayland-only builds, while rearranging jobs by host OS instead of by target platform. Every useful combination of platforms is now being built, except for Null-only with Win32 time and threading. This combination does not compile on VS due to some non-standard array initializers. --- .github/workflows/build.yml | 109 ++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 28c2d18d..b3431198 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,31 +9,8 @@ permissions: contents: read jobs: - build-linux-x11-clang: - name: X11 (Linux, Clang) - runs-on: ubuntu-latest - env: - CC: clang - CFLAGS: -Werror - steps: - - uses: actions/checkout@v3 - - name: Install dependencies - run: | - sudo apt update - sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev - - - name: Configure static library - run: cmake -B build-static - - name: Build static library - run: cmake --build build-static --parallel - - - name: Configure shared library - run: cmake -B build-shared -D BUILD_SHARED_LIBS=ON - - name: Build shared library - run: cmake --build build-shared --parallel - - build-linux-full-clang: - name: X11+Wayland (Linux, Clang) + build-linux-clang: + name: Linux (Clang) runs-on: ubuntu-latest env: CC: clang @@ -45,50 +22,76 @@ jobs: sudo apt update sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev wayland-protocols libwayland-dev libxkbcommon-dev - - name: Configure static library - run: cmake -B build-static -D GLFW_BUILD_WAYLAND=ON - - name: Build static library - run: cmake --build build-static --parallel + - name: Configure Null shared library + run: cmake -B build-null-shared -D GLFW_BUILD_WAYLAND=OFF -D GLFW_BUILD_X11=OFF -D BUILD_SHARED_LIBS=ON + - name: Build Null shared library + run: cmake --build build-null-shared --parallel - - name: Configure shared library - run: cmake -B build-shared -D GLFW_BUILD_WAYLAND=ON -D BUILD_SHARED_LIBS=ON - - name: Build shared library - run: cmake --build build-shared --parallel + - name: Configure X11 shared library + run: cmake -B build-x11-shared -D GLFW_BUILD_WAYLAND=OFF -D GLFW_BUILD_X11=ON -D BUILD_SHARED_LIBS=ON + - name: Build X11 shared library + run: cmake --build build-x11-shared --parallel - build-macos-cocoa-clang: - name: Cocoa (macOS, Clang) + - name: Configure Wayland shared library + run: cmake -B build-wayland-shared -D GLFW_BUILD_WAYLAND=ON -D GLFW_BUILD_X11=OFF -D BUILD_SHARED_LIBS=ON + - name: Build Wayland shared library + run: cmake --build build-wayland-shared --parallel + + - name: Configure Wayland+X11 static library + run: cmake -B build-full-static -D GLFW_BUILD_WAYLAND=ON -D GLFW_BUILD_X11=ON + - name: Build Wayland+X11 static library + run: cmake --build build-full-static --parallel + + - name: Configure Wayland+X11 shared library + run: cmake -B build-full-shared -D GLFW_BUILD_WAYLAND=ON -D BUILD_SHARED_LIBS=ON -D GLFW_BUILD_X11=ON + - name: Build Wayland+X11 shared library + run: cmake --build build-full-shared --parallel + + build-macos-clang: + name: macOS (Clang) runs-on: macos-latest env: CFLAGS: -Werror MACOSX_DEPLOYMENT_TARGET: 10.8 + CMAKE_OSX_ARCHITECTURES: x86_64;arm64 steps: - uses: actions/checkout@v3 - - name: Configure static library - run: cmake -B build-static - - name: Build static library - run: cmake --build build-static --parallel + - name: Configure Null shared library + run: cmake -B build-null-shared -D GLFW_BUILD_COCOA=OFF -D BUILD_SHARED_LIBS=ON + - name: Build Null shared library + run: cmake --build build-null-shared --parallel - - name: Configure shared library - run: cmake -B build-shared -D BUILD_SHARED_LIBS=ON - - name: Build shared library - run: cmake --build build-shared --parallel + - name: Configure Cocoa static library + run: cmake -B build-cocoa-static + - name: Build Cocoa static library + run: cmake --build build-cocoa-static --parallel - build-windows-win32-vs2022: - name: Win32 (Windows, VS2022) + - name: Configure Cocoa shared library + run: cmake -B build-cocoa-shared -D BUILD_SHARED_LIBS=ON + - name: Build Cocoa shared library + run: cmake --build build-cocoa-shared --parallel + + build-windows-vs2022: + name: Windows (VS2022) runs-on: windows-latest env: CFLAGS: /WX steps: - uses: actions/checkout@v3 - - name: Configure static library - run: cmake -B build-static -G "Visual Studio 17 2022" - - name: Build static library - run: cmake --build build-static --parallel + - name: Configure Win32 shared x86 library + run: cmake -B build-win32-shared-x86 -G "Visual Studio 17 2022" -A Win32 -D BUILD_SHARED_LIBS=ON + - name: Build Win32 shared x86 library + run: cmake --build build-win32-shared-x86 --parallel - - name: Configure shared library - run: cmake -B build-shared -G "Visual Studio 17 2022" -D BUILD_SHARED_LIBS=ON - - name: Build shared library - run: cmake --build build-shared --parallel + - name: Configure Win32 static x64 library + run: cmake -B build-win32-static-x64 -G "Visual Studio 17 2022" -A x64 + - name: Build Win32 static x64 library + run: cmake --build build-win32-static-x64 --parallel + + - name: Configure Win32 shared x64 library + run: cmake -B build-win32-shared-x64 -G "Visual Studio 17 2022" -A x64 -D BUILD_SHARED_LIBS=ON + - name: Build Win32 shared x64 library + run: cmake --build build-win32-shared-x64 --parallel From d9646631d6669c6006f31b1bbb5e14909165e7cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 15 Dec 2023 00:12:38 +0100 Subject: [PATCH 006/137] Removed unused header in sharing example --- examples/sharing.c | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/sharing.c b/examples/sharing.c index d840c58c..502f9eea 100644 --- a/examples/sharing.c +++ b/examples/sharing.c @@ -31,7 +31,6 @@ #include #include -#include "getopt.h" #include "linmath.h" static const char* vertex_shader_text = From 4e8c4901e9985765a3951423ff9174459339a62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 3 Jan 2024 18:01:29 +0100 Subject: [PATCH 007/137] Wayland: Fix segfault on termination A segfault could occur during termination if libdecor was found but no windows were created between initialization and termination. The wait for libdecor to finish its initialization was only performed before window creation, not at termination. Regression introduced by 9fdc425931888ea70bc095e53cc006fca8ccb703. --- src/wl_init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 0ec65900..fd6b7e9c 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -846,10 +846,15 @@ void _glfwTerminateWayland(void) _glfwTerminateEGL(); _glfwTerminateOSMesa(); - if (_glfw.wl.libdecor.callback) - wl_callback_destroy(_glfw.wl.libdecor.callback); if (_glfw.wl.libdecor.context) + { + // Allow libdecor to finish receiving all its requested globals + // and ensure the associated sync callback object is destroyed + while (!_glfw.wl.libdecor.ready) + _glfwWaitEventsWayland(); + libdecor_unref(_glfw.wl.libdecor.context); + } if (_glfw.wl.libdecor.handle) { From 5a9ea8f99f27cfb0bf47ecc23fdc24e98098de6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 3 Jan 2024 18:01:56 +0100 Subject: [PATCH 008/137] Add build- prefix to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 84636a0a..9d2d504b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # The canonical out-of-tree build subdirectory build +build-* # Visual Studio clutter _ReSharper* From 73948e6c0f15b1053cf74b7c4e6b04fd36e97e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 4 Jan 2024 20:07:27 +0100 Subject: [PATCH 009/137] Fix missing error in docs for glfwCreateWindow The GLFW_NO_WINDOW_CONTEXT error can be emitted if the window passed in for context sharing does not have a context. Fixes #2456 --- 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 eb98dafd..c947f17d 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3089,8 +3089,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref - * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref - * GLFW_PLATFORM_ERROR. + * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref + * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. * * @remark @win32 Window creation will fail if the Microsoft GDI software * OpenGL implementation is the only one available. From 2c3eb75748584c1c9283787e8c40f944fa055d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Dec 2023 23:03:25 +0100 Subject: [PATCH 010/137] Wayland: Remove dependency on wayland-protocols This brings the latest released versions of all used Wayland protocol files into this repository, removing the need for the user to arrange a sufficiently new version of wayland-protocols. The wayland.xml protocol file was copied from wayland 1.22.0. The additional protocol files were copied from wayland-protocols 1.32. Because of how files are moved and renamed inside the wayland-protocols repository, it will not always be possible to update all our protocol files from a single release without also potentially updating related code (acceptable) and prematurely breaking compatibility with compositors that still only support an earlier incompatible version (unacceptable). The macro in src/CMakeLists.txt has been modified to hopefully make it easier to add new protocol files. This made it necessary to change the name of a few of the generated header files. Closes #2053 --- .github/workflows/build.yml | 2 +- deps/wayland/idle-inhibit-unstable-v1.xml | 83 + .../pointer-constraints-unstable-v1.xml | 339 ++ deps/wayland/relative-pointer-unstable-v1.xml | 136 + deps/wayland/viewporter.xml | 180 + deps/wayland/wayland.xml | 3151 +++++++++++++++++ deps/wayland/xdg-decoration-unstable-v1.xml | 156 + deps/wayland/xdg-shell.xml | 1370 +++++++ docs/compat.dox | 65 +- docs/compile.dox | 23 +- src/CMakeLists.txt | 57 +- src/wl_init.c | 26 +- src/wl_monitor.c | 10 - src/wl_window.c | 16 +- 14 files changed, 5497 insertions(+), 117 deletions(-) create mode 100644 deps/wayland/idle-inhibit-unstable-v1.xml create mode 100644 deps/wayland/pointer-constraints-unstable-v1.xml create mode 100644 deps/wayland/relative-pointer-unstable-v1.xml create mode 100644 deps/wayland/viewporter.xml create mode 100644 deps/wayland/wayland.xml create mode 100644 deps/wayland/xdg-decoration-unstable-v1.xml create mode 100644 deps/wayland/xdg-shell.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b3431198..11d111cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: - name: Install dependencies run: | sudo apt update - sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev wayland-protocols libwayland-dev libxkbcommon-dev + sudo apt install libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev libwayland-dev libxkbcommon-dev - name: Configure Null shared library run: cmake -B build-null-shared -D GLFW_BUILD_WAYLAND=OFF -D GLFW_BUILD_X11=OFF -D BUILD_SHARED_LIBS=ON diff --git a/deps/wayland/idle-inhibit-unstable-v1.xml b/deps/wayland/idle-inhibit-unstable-v1.xml new file mode 100644 index 00000000..9c06cdcb --- /dev/null +++ b/deps/wayland/idle-inhibit-unstable-v1.xml @@ -0,0 +1,83 @@ + + + + + Copyright © 2015 Samsung Electronics Co., Ltd + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + + This interface permits inhibiting the idle behavior such as screen + blanking, locking, and screensaving. The client binds the idle manager + globally, then creates idle-inhibitor objects for each surface. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + + + + + Destroy the inhibit manager. + + + + + + Create a new inhibitor object associated with the given surface. + + + + + + + + + + An idle inhibitor prevents the output that the associated surface is + visible on from being set to a state where it is not visually usable due + to lack of user interaction (e.g. blanked, dimmed, locked, set to power + save, etc.) Any screensaver processes are also blocked from displaying. + + If the surface is destroyed, unmapped, becomes occluded, loses + visibility, or otherwise becomes not visually relevant for the user, the + idle inhibitor will not be honored by the compositor; if the surface + subsequently regains visibility the inhibitor takes effect once again. + Likewise, the inhibitor isn't honored if the system was already idled at + the time the inhibitor was established, although if the system later + de-idles and re-idles the inhibitor will take effect. + + + + + Remove the inhibitor effect from the associated wl_surface. + + + + + diff --git a/deps/wayland/pointer-constraints-unstable-v1.xml b/deps/wayland/pointer-constraints-unstable-v1.xml new file mode 100644 index 00000000..efd64b66 --- /dev/null +++ b/deps/wayland/pointer-constraints-unstable-v1.xml @@ -0,0 +1,339 @@ + + + + + Copyright © 2014 Jonas Ådahl + Copyright © 2015 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + This protocol specifies a set of interfaces used for adding constraints to + the motion of a pointer. Possible constraints include confining pointer + motions to a given region, or locking it to its current position. + + In order to constrain the pointer, a client must first bind the global + interface "wp_pointer_constraints" which, if a compositor supports pointer + constraints, is exposed by the registry. Using the bound global object, the + client uses the request that corresponds to the type of constraint it wants + to make. See wp_pointer_constraints for more details. + + Warning! The protocol described in this file is experimental and backward + incompatible changes may be made. Backward compatible changes may be added + together with the corresponding interface version bump. Backward + incompatible changes are done by bumping the version number in the protocol + and interface names and resetting the interface version. Once the protocol + is to be declared stable, the 'z' prefix and the version number in the + protocol and interface names are removed and the interface version number is + reset. + + + + + The global interface exposing pointer constraining functionality. It + exposes two requests: lock_pointer for locking the pointer to its + position, and confine_pointer for locking the pointer to a region. + + The lock_pointer and confine_pointer requests create the objects + wp_locked_pointer and wp_confined_pointer respectively, and the client can + use these objects to interact with the lock. + + For any surface, only one lock or confinement may be active across all + wl_pointer objects of the same seat. If a lock or confinement is requested + when another lock or confinement is active or requested on the same surface + and with any of the wl_pointer objects of the same seat, an + 'already_constrained' error will be raised. + + + + + These errors can be emitted in response to wp_pointer_constraints + requests. + + + + + + + These values represent different lifetime semantics. They are passed + as arguments to the factory requests to specify how the constraint + lifetimes should be managed. + + + + A oneshot pointer constraint will never reactivate once it has been + deactivated. See the corresponding deactivation event + (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for + details. + + + + + A persistent pointer constraint may again reactivate once it has + been deactivated. See the corresponding deactivation event + (wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for + details. + + + + + + + Used by the client to notify the server that it will no longer use this + pointer constraints object. + + + + + + The lock_pointer request lets the client request to disable movements of + the virtual pointer (i.e. the cursor), effectively locking the pointer + to a position. This request may not take effect immediately; in the + future, when the compositor deems implementation-specific constraints + are satisfied, the pointer lock will be activated and the compositor + sends a locked event. + + The protocol provides no guarantee that the constraints are ever + satisfied, and does not require the compositor to send an error if the + constraints cannot ever be satisfied. It is thus possible to request a + lock that will never activate. + + There may not be another pointer constraint of any kind requested or + active on the surface for any of the wl_pointer objects of the seat of + the passed pointer when requesting a lock. If there is, an error will be + raised. See general pointer lock documentation for more details. + + The intersection of the region passed with this request and the input + region of the surface is used to determine where the pointer must be + in order for the lock to activate. It is up to the compositor whether to + warp the pointer or require some kind of user interaction for the lock + to activate. If the region is null the surface input region is used. + + A surface may receive pointer focus without the lock being activated. + + The request creates a new object wp_locked_pointer which is used to + interact with the lock as well as receive updates about its state. See + the the description of wp_locked_pointer for further information. + + Note that while a pointer is locked, the wl_pointer objects of the + corresponding seat will not emit any wl_pointer.motion events, but + relative motion events will still be emitted via wp_relative_pointer + objects of the same seat. wl_pointer.axis and wl_pointer.button events + are unaffected. + + + + + + + + + + + The confine_pointer request lets the client request to confine the + pointer cursor to a given region. This request may not take effect + immediately; in the future, when the compositor deems implementation- + specific constraints are satisfied, the pointer confinement will be + activated and the compositor sends a confined event. + + The intersection of the region passed with this request and the input + region of the surface is used to determine where the pointer must be + in order for the confinement to activate. It is up to the compositor + whether to warp the pointer or require some kind of user interaction for + the confinement to activate. If the region is null the surface input + region is used. + + The request will create a new object wp_confined_pointer which is used + to interact with the confinement as well as receive updates about its + state. See the the description of wp_confined_pointer for further + information. + + + + + + + + + + + + The wp_locked_pointer interface represents a locked pointer state. + + While the lock of this object is active, the wl_pointer objects of the + associated seat will not emit any wl_pointer.motion events. + + This object will send the event 'locked' when the lock is activated. + Whenever the lock is activated, it is guaranteed that the locked surface + will already have received pointer focus and that the pointer will be + within the region passed to the request creating this object. + + To unlock the pointer, send the destroy request. This will also destroy + the wp_locked_pointer object. + + If the compositor decides to unlock the pointer the unlocked event is + sent. See wp_locked_pointer.unlock for details. + + When unlocking, the compositor may warp the cursor position to the set + cursor position hint. If it does, it will not result in any relative + motion events emitted via wp_relative_pointer. + + If the surface the lock was requested on is destroyed and the lock is not + yet activated, the wp_locked_pointer object is now defunct and must be + destroyed. + + + + + Destroy the locked pointer object. If applicable, the compositor will + unlock the pointer. + + + + + + Set the cursor position hint relative to the top left corner of the + surface. + + If the client is drawing its own cursor, it should update the position + hint to the position of its own cursor. A compositor may use this + information to warp the pointer upon unlock in order to avoid pointer + jumps. + + The cursor position hint is double buffered. The new hint will only take + effect when the associated surface gets it pending state applied. See + wl_surface.commit for details. + + + + + + + + Set a new region used to lock the pointer. + + The new lock region is double-buffered. The new lock region will + only take effect when the associated surface gets its pending state + applied. See wl_surface.commit for details. + + For details about the lock region, see wp_locked_pointer. + + + + + + + Notification that the pointer lock of the seat's pointer is activated. + + + + + + Notification that the pointer lock of the seat's pointer is no longer + active. If this is a oneshot pointer lock (see + wp_pointer_constraints.lifetime) this object is now defunct and should + be destroyed. If this is a persistent pointer lock (see + wp_pointer_constraints.lifetime) this pointer lock may again + reactivate in the future. + + + + + + + The wp_confined_pointer interface represents a confined pointer state. + + This object will send the event 'confined' when the confinement is + activated. Whenever the confinement is activated, it is guaranteed that + the surface the pointer is confined to will already have received pointer + focus and that the pointer will be within the region passed to the request + creating this object. It is up to the compositor to decide whether this + requires some user interaction and if the pointer will warp to within the + passed region if outside. + + To unconfine the pointer, send the destroy request. This will also destroy + the wp_confined_pointer object. + + If the compositor decides to unconfine the pointer the unconfined event is + sent. The wp_confined_pointer object is at this point defunct and should + be destroyed. + + + + + Destroy the confined pointer object. If applicable, the compositor will + unconfine the pointer. + + + + + + Set a new region used to confine the pointer. + + The new confine region is double-buffered. The new confine region will + only take effect when the associated surface gets its pending state + applied. See wl_surface.commit for details. + + If the confinement is active when the new confinement region is applied + and the pointer ends up outside of newly applied region, the pointer may + warped to a position within the new confinement region. If warped, a + wl_pointer.motion event will be emitted, but no + wp_relative_pointer.relative_motion event. + + The compositor may also, instead of using the new region, unconfine the + pointer. + + For details about the confine region, see wp_confined_pointer. + + + + + + + Notification that the pointer confinement of the seat's pointer is + activated. + + + + + + Notification that the pointer confinement of the seat's pointer is no + longer active. If this is a oneshot pointer confinement (see + wp_pointer_constraints.lifetime) this object is now defunct and should + be destroyed. If this is a persistent pointer confinement (see + wp_pointer_constraints.lifetime) this pointer confinement may again + reactivate in the future. + + + + + diff --git a/deps/wayland/relative-pointer-unstable-v1.xml b/deps/wayland/relative-pointer-unstable-v1.xml new file mode 100644 index 00000000..ca6f81d1 --- /dev/null +++ b/deps/wayland/relative-pointer-unstable-v1.xml @@ -0,0 +1,136 @@ + + + + + Copyright © 2014 Jonas Ådahl + Copyright © 2015 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + This protocol specifies a set of interfaces used for making clients able to + receive relative pointer events not obstructed by barriers (such as the + monitor edge or other pointer barriers). + + To start receiving relative pointer events, a client must first bind the + global interface "wp_relative_pointer_manager" which, if a compositor + supports relative pointer motion events, is exposed by the registry. After + having created the relative pointer manager proxy object, the client uses + it to create the actual relative pointer object using the + "get_relative_pointer" request given a wl_pointer. The relative pointer + motion events will then, when applicable, be transmitted via the proxy of + the newly created relative pointer object. See the documentation of the + relative pointer interface for more details. + + Warning! The protocol described in this file is experimental and backward + incompatible changes may be made. Backward compatible changes may be added + together with the corresponding interface version bump. Backward + incompatible changes are done by bumping the version number in the protocol + and interface names and resetting the interface version. Once the protocol + is to be declared stable, the 'z' prefix and the version number in the + protocol and interface names are removed and the interface version number is + reset. + + + + + A global interface used for getting the relative pointer object for a + given pointer. + + + + + Used by the client to notify the server that it will no longer use this + relative pointer manager object. + + + + + + Create a relative pointer interface given a wl_pointer object. See the + wp_relative_pointer interface for more details. + + + + + + + + + A wp_relative_pointer object is an extension to the wl_pointer interface + used for emitting relative pointer events. It shares the same focus as + wl_pointer objects of the same seat and will only emit events when it has + focus. + + + + + + + + + Relative x/y pointer motion from the pointer of the seat associated with + this object. + + A relative motion is in the same dimension as regular wl_pointer motion + events, except they do not represent an absolute position. For example, + moving a pointer from (x, y) to (x', y') would have the equivalent + relative motion (x' - x, y' - y). If a pointer motion caused the + absolute pointer position to be clipped by for example the edge of the + monitor, the relative motion is unaffected by the clipping and will + represent the unclipped motion. + + This event also contains non-accelerated motion deltas. The + non-accelerated delta is, when applicable, the regular pointer motion + delta as it was before having applied motion acceleration and other + transformations such as normalization. + + Note that the non-accelerated delta does not represent 'raw' events as + they were read from some device. Pointer motion acceleration is device- + and configuration-specific and non-accelerated deltas and accelerated + deltas may have the same value on some devices. + + Relative motions are not coupled to wl_pointer.motion events, and can be + sent in combination with such events, but also independently. There may + also be scenarios where wl_pointer.motion is sent, but there is no + relative motion. The order of an absolute and relative motion event + originating from the same physical motion is not guaranteed. + + If the client needs button events or focus state, it can receive them + from a wl_pointer object of the same seat that the wp_relative_pointer + object is associated with. + + + + + + + + + + + diff --git a/deps/wayland/viewporter.xml b/deps/wayland/viewporter.xml new file mode 100644 index 00000000..d1048d1f --- /dev/null +++ b/deps/wayland/viewporter.xml @@ -0,0 +1,180 @@ + + + + + Copyright © 2013-2016 Collabora, Ltd. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + + The global interface exposing surface cropping and scaling + capabilities is used to instantiate an interface extension for a + wl_surface object. This extended interface will then allow + cropping and scaling the surface contents, effectively + disconnecting the direct relationship between the buffer and the + surface size. + + + + + Informs the server that the client will not be using this + protocol object anymore. This does not affect any other objects, + wp_viewport objects included. + + + + + + + + + + Instantiate an interface extension for the given wl_surface to + crop and scale its content. If the given wl_surface already has + a wp_viewport object associated, the viewport_exists + protocol error is raised. + + + + + + + + + An additional interface to a wl_surface object, which allows the + client to specify the cropping and scaling of the surface + contents. + + This interface works with two concepts: the source rectangle (src_x, + src_y, src_width, src_height), and the destination size (dst_width, + dst_height). The contents of the source rectangle are scaled to the + destination size, and content outside the source rectangle is ignored. + This state is double-buffered, and is applied on the next + wl_surface.commit. + + The two parts of crop and scale state are independent: the source + rectangle, and the destination size. Initially both are unset, that + is, no scaling is applied. The whole of the current wl_buffer is + used as the source, and the surface size is as defined in + wl_surface.attach. + + If the destination size is set, it causes the surface size to become + dst_width, dst_height. The source (rectangle) is scaled to exactly + this size. This overrides whatever the attached wl_buffer size is, + unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface + has no content and therefore no size. Otherwise, the size is always + at least 1x1 in surface local coordinates. + + If the source rectangle is set, it defines what area of the wl_buffer is + taken as the source. If the source rectangle is set and the destination + size is not set, then src_width and src_height must be integers, and the + surface size becomes the source rectangle size. This results in cropping + without scaling. If src_width or src_height are not integers and + destination size is not set, the bad_size protocol error is raised when + the surface state is applied. + + The coordinate transformations from buffer pixel coordinates up to + the surface-local coordinates happen in the following order: + 1. buffer_transform (wl_surface.set_buffer_transform) + 2. buffer_scale (wl_surface.set_buffer_scale) + 3. crop and scale (wp_viewport.set*) + This means, that the source rectangle coordinates of crop and scale + are given in the coordinates after the buffer transform and scale, + i.e. in the coordinates that would be the surface-local coordinates + if the crop and scale was not applied. + + If src_x or src_y are negative, the bad_value protocol error is raised. + Otherwise, if the source rectangle is partially or completely outside of + the non-NULL wl_buffer, then the out_of_buffer protocol error is raised + when the surface state is applied. A NULL wl_buffer does not raise the + out_of_buffer error. + + If the wl_surface associated with the wp_viewport is destroyed, + all wp_viewport requests except 'destroy' raise the protocol error + no_surface. + + If the wp_viewport object is destroyed, the crop and scale + state is removed from the wl_surface. The change will be applied + on the next wl_surface.commit. + + + + + The associated wl_surface's crop and scale state is removed. + The change is applied on the next wl_surface.commit. + + + + + + + + + + + + + Set the source rectangle of the associated wl_surface. See + wp_viewport for the description, and relation to the wl_buffer + size. + + If all of x, y, width and height are -1.0, the source rectangle is + unset instead. Any other set of values where width or height are zero + or negative, or x or y are negative, raise the bad_value protocol + error. + + The crop and scale state is double-buffered state, and will be + applied on the next wl_surface.commit. + + + + + + + + + + Set the destination size of the associated wl_surface. See + wp_viewport for the description, and relation to the wl_buffer + size. + + If width is -1 and height is -1, the destination size is unset + instead. Any other pair of values for width and height that + contains zero or negative values raises the bad_value protocol + error. + + The crop and scale state is double-buffered state, and will be + applied on the next wl_surface.commit. + + + + + + + diff --git a/deps/wayland/wayland.xml b/deps/wayland/wayland.xml new file mode 100644 index 00000000..10e039d6 --- /dev/null +++ b/deps/wayland/wayland.xml @@ -0,0 +1,3151 @@ + + + + + Copyright © 2008-2011 Kristian Høgsberg + Copyright © 2010-2011 Intel Corporation + Copyright © 2012-2013 Collabora, Ltd. + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation files + (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice (including the + next paragraph) shall be included in all copies or substantial + portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + + + + + The core global object. This is a special singleton object. It + is used for internal Wayland protocol features. + + + + + The sync request asks the server to emit the 'done' event + on the returned wl_callback object. Since requests are + handled in-order and events are delivered in-order, this can + be used as a barrier to ensure all previous requests and the + resulting events have been handled. + + The object returned by this request will be destroyed by the + compositor after the callback is fired and as such the client must not + attempt to use it after that point. + + The callback_data passed in the callback is the event serial. + + + + + + + This request creates a registry object that allows the client + to list and bind the global objects available from the + compositor. + + It should be noted that the server side resources consumed in + response to a get_registry request can only be released when the + client disconnects, not when the client side proxy is destroyed. + Therefore, clients should invoke get_registry as infrequently as + possible to avoid wasting memory. + + + + + + + The error event is sent out when a fatal (non-recoverable) + error has occurred. The object_id argument is the object + where the error occurred, most often in response to a request + to that object. The code identifies the error and is defined + by the object interface. As such, each interface defines its + own set of error codes. The message is a brief description + of the error, for (debugging) convenience. + + + + + + + + + These errors are global and can be emitted in response to any + server request. + + + + + + + + + + This event is used internally by the object ID management + logic. When a client deletes an object that it had created, + the server will send this event to acknowledge that it has + seen the delete request. When the client receives this event, + it will know that it can safely reuse the object ID. + + + + + + + + The singleton global registry object. The server has a number of + global objects that are available to all clients. These objects + typically represent an actual object in the server (for example, + an input device) or they are singleton objects that provide + extension functionality. + + When a client creates a registry object, the registry object + will emit a global event for each global currently in the + registry. Globals come and go as a result of device or + monitor hotplugs, reconfiguration or other events, and the + registry will send out global and global_remove events to + keep the client up to date with the changes. To mark the end + of the initial burst of events, the client can use the + wl_display.sync request immediately after calling + wl_display.get_registry. + + A client can bind to a global object by using the bind + request. This creates a client-side handle that lets the object + emit events to the client and lets the client invoke requests on + the object. + + + + + Binds a new, client-created object to the server using the + specified name as the identifier. + + + + + + + + Notify the client of global objects. + + The event notifies the client that a global object with + the given name is now available, and it implements the + given version of the given interface. + + + + + + + + + Notify the client of removed global objects. + + This event notifies the client that the global identified + by name is no longer available. If the client bound to + the global using the bind request, the client should now + destroy that object. + + The object remains valid and requests to the object will be + ignored until the client destroys it, to avoid races between + the global going away and a client sending a request to it. + + + + + + + + Clients can handle the 'done' event to get notified when + the related request is done. + + Note, because wl_callback objects are created from multiple independent + factory interfaces, the wl_callback interface is frozen at version 1. + + + + + Notify the client when the related request is done. + + + + + + + + A compositor. This object is a singleton global. The + compositor is in charge of combining the contents of multiple + surfaces into one displayable output. + + + + + Ask the compositor to create a new surface. + + + + + + + Ask the compositor to create a new region. + + + + + + + + The wl_shm_pool object encapsulates a piece of memory shared + between the compositor and client. Through the wl_shm_pool + object, the client can allocate shared memory wl_buffer objects. + All objects created through the same pool share the same + underlying mapped memory. Reusing the mapped memory avoids the + setup/teardown overhead and is useful when interactively resizing + a surface or for many small buffers. + + + + + Create a wl_buffer object from the pool. + + The buffer is created offset bytes into the pool and has + width and height as specified. The stride argument specifies + the number of bytes from the beginning of one row to the beginning + of the next. The format is the pixel format of the buffer and + must be one of those advertised through the wl_shm.format event. + + A buffer will keep a reference to the pool it was created from + so it is valid to destroy the pool immediately after creating + a buffer from it. + + + + + + + + + + + + Destroy the shared memory pool. + + The mmapped memory will be released when all + buffers that have been created from this pool + are gone. + + + + + + This request will cause the server to remap the backing memory + for the pool from the file descriptor passed when the pool was + created, but using the new size. This request can only be + used to make the pool bigger. + + This request only changes the amount of bytes that are mmapped + by the server and does not touch the file corresponding to the + file descriptor passed at creation time. It is the client's + responsibility to ensure that the file is at least as big as + the new pool size. + + + + + + + + A singleton global object that provides support for shared + memory. + + Clients can create wl_shm_pool objects using the create_pool + request. + + On binding the wl_shm object one or more format events + are emitted to inform clients about the valid pixel formats + that can be used for buffers. + + + + + These errors can be emitted in response to wl_shm requests. + + + + + + + + + This describes the memory layout of an individual pixel. + + All renderers should support argb8888 and xrgb8888 but any other + formats are optional and may not be supported by the particular + renderer in use. + + The drm format codes match the macros defined in drm_fourcc.h, except + argb8888 and xrgb8888. The formats actually supported by the compositor + will be reported by the format event. + + For all wl_shm formats and unless specified in another protocol + extension, pre-multiplied alpha is used for pixel values. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create a new wl_shm_pool object. + + The pool can be used to create shared memory based buffer + objects. The server will mmap size bytes of the passed file + descriptor, to use as backing memory for the pool. + + + + + + + + + Informs the client about a valid pixel format that + can be used for buffers. Known formats include + argb8888 and xrgb8888. + + + + + + + + A buffer provides the content for a wl_surface. Buffers are + created through factory interfaces such as wl_shm, wp_linux_buffer_params + (from the linux-dmabuf protocol extension) or similar. It has a width and + a height and can be attached to a wl_surface, but the mechanism by which a + client provides and updates the contents is defined by the buffer factory + interface. + + If the buffer uses a format that has an alpha channel, the alpha channel + is assumed to be premultiplied in the color channels unless otherwise + specified. + + Note, because wl_buffer objects are created from multiple independent + factory interfaces, the wl_buffer interface is frozen at version 1. + + + + + Destroy a buffer. If and how you need to release the backing + storage is defined by the buffer factory interface. + + For possible side-effects to a surface, see wl_surface.attach. + + + + + + Sent when this wl_buffer is no longer used by the compositor. + The client is now free to reuse or destroy this buffer and its + backing storage. + + If a client receives a release event before the frame callback + requested in the same wl_surface.commit that attaches this + wl_buffer to a surface, then the client is immediately free to + reuse the buffer and its backing storage, and does not need a + second buffer for the next surface content update. Typically + this is possible, when the compositor maintains a copy of the + wl_surface contents, e.g. as a GL texture. This is an important + optimization for GL(ES) compositors with wl_shm clients. + + + + + + + A wl_data_offer represents a piece of data offered for transfer + by another client (the source client). It is used by the + copy-and-paste and drag-and-drop mechanisms. The offer + describes the different mime types that the data can be + converted to and provides the mechanism for transferring the + data directly from the source client. + + + + + + + + + + + + Indicate that the client can accept the given mime type, or + NULL for not accepted. + + For objects of version 2 or older, this request is used by the + client to give feedback whether the client can receive the given + mime type, or NULL if none is accepted; the feedback does not + determine whether the drag-and-drop operation succeeds or not. + + For objects of version 3 or newer, this request determines the + final result of the drag-and-drop operation. If the end result + is that no mime types were accepted, the drag-and-drop operation + will be cancelled and the corresponding drag source will receive + wl_data_source.cancelled. Clients may still use this event in + conjunction with wl_data_source.action for feedback. + + + + + + + + To transfer the offered data, the client issues this request + and indicates the mime type it wants to receive. The transfer + happens through the passed file descriptor (typically created + with the pipe system call). The source client writes the data + in the mime type representation requested and then closes the + file descriptor. + + The receiving client reads from the read end of the pipe until + EOF and then closes its end, at which point the transfer is + complete. + + This request may happen multiple times for different mime types, + both before and after wl_data_device.drop. Drag-and-drop destination + clients may preemptively fetch data or examine it more closely to + determine acceptance. + + + + + + + + Destroy the data offer. + + + + + + Sent immediately after creating the wl_data_offer object. One + event per offered mime type. + + + + + + + + + Notifies the compositor that the drag destination successfully + finished the drag-and-drop operation. + + Upon receiving this request, the compositor will emit + wl_data_source.dnd_finished on the drag source client. + + It is a client error to perform other requests than + wl_data_offer.destroy after this one. It is also an error to perform + this request after a NULL mime type has been set in + wl_data_offer.accept or no action was received through + wl_data_offer.action. + + If wl_data_offer.finish request is received for a non drag and drop + operation, the invalid_finish protocol error is raised. + + + + + + Sets the actions that the destination side client supports for + this operation. This request may trigger the emission of + wl_data_source.action and wl_data_offer.action events if the compositor + needs to change the selected action. + + This request can be called multiple times throughout the + drag-and-drop operation, typically in response to wl_data_device.enter + or wl_data_device.motion events. + + This request determines the final result of the drag-and-drop + operation. If the end result is that no action is accepted, + the drag source will receive wl_data_source.cancelled. + + The dnd_actions argument must contain only values expressed in the + wl_data_device_manager.dnd_actions enum, and the preferred_action + argument must only contain one of those values set, otherwise it + will result in a protocol error. + + While managing an "ask" action, the destination drag-and-drop client + may perform further wl_data_offer.receive requests, and is expected + to perform one last wl_data_offer.set_actions request with a preferred + action other than "ask" (and optionally wl_data_offer.accept) before + requesting wl_data_offer.finish, in order to convey the action selected + by the user. If the preferred action is not in the + wl_data_offer.source_actions mask, an error will be raised. + + If the "ask" action is dismissed (e.g. user cancellation), the client + is expected to perform wl_data_offer.destroy right away. + + This request can only be made on drag-and-drop offers, a protocol error + will be raised otherwise. + + + + + + + + This event indicates the actions offered by the data source. It + will be sent immediately after creating the wl_data_offer object, + or anytime the source side changes its offered actions through + wl_data_source.set_actions. + + + + + + + This event indicates the action selected by the compositor after + matching the source/destination side actions. Only one action (or + none) will be offered here. + + This event can be emitted multiple times during the drag-and-drop + operation in response to destination side action changes through + wl_data_offer.set_actions. + + This event will no longer be emitted after wl_data_device.drop + happened on the drag-and-drop destination, the client must + honor the last action received, or the last preferred one set + through wl_data_offer.set_actions when handling an "ask" action. + + Compositors may also change the selected action on the fly, mainly + in response to keyboard modifier changes during the drag-and-drop + operation. + + The most recent action received is always the valid one. Prior to + receiving wl_data_device.drop, the chosen action may change (e.g. + due to keyboard modifiers being pressed). At the time of receiving + wl_data_device.drop the drag-and-drop destination must honor the + last action received. + + Action changes may still happen after wl_data_device.drop, + especially on "ask" actions, where the drag-and-drop destination + may choose another action afterwards. Action changes happening + at this stage are always the result of inter-client negotiation, the + compositor shall no longer be able to induce a different action. + + Upon "ask" actions, it is expected that the drag-and-drop destination + may potentially choose a different action and/or mime type, + based on wl_data_offer.source_actions and finally chosen by the + user (e.g. popping up a menu with the available options). The + final wl_data_offer.set_actions and wl_data_offer.accept requests + must happen before the call to wl_data_offer.finish. + + + + + + + + The wl_data_source object is the source side of a wl_data_offer. + It is created by the source client in a data transfer and + provides a way to describe the offered data and a way to respond + to requests to transfer the data. + + + + + + + + + + This request adds a mime type to the set of mime types + advertised to targets. Can be called several times to offer + multiple types. + + + + + + + Destroy the data source. + + + + + + Sent when a target accepts pointer_focus or motion events. If + a target does not accept any of the offered types, type is NULL. + + Used for feedback during drag-and-drop. + + + + + + + Request for data from the client. Send the data as the + specified mime type over the passed file descriptor, then + close it. + + + + + + + + This data source is no longer valid. There are several reasons why + this could happen: + + - The data source has been replaced by another data source. + - The drag-and-drop operation was performed, but the drop destination + did not accept any of the mime types offered through + wl_data_source.target. + - The drag-and-drop operation was performed, but the drop destination + did not select any of the actions present in the mask offered through + wl_data_source.action. + - The drag-and-drop operation was performed but didn't happen over a + surface. + - The compositor cancelled the drag-and-drop operation (e.g. compositor + dependent timeouts to avoid stale drag-and-drop transfers). + + The client should clean up and destroy this data source. + + For objects of version 2 or older, wl_data_source.cancelled will + only be emitted if the data source was replaced by another data + source. + + + + + + + + Sets the actions that the source side client supports for this + operation. This request may trigger wl_data_source.action and + wl_data_offer.action events if the compositor needs to change the + selected action. + + The dnd_actions argument must contain only values expressed in the + wl_data_device_manager.dnd_actions enum, otherwise it will result + in a protocol error. + + This request must be made once only, and can only be made on sources + used in drag-and-drop, so it must be performed before + wl_data_device.start_drag. Attempting to use the source other than + for drag-and-drop will raise a protocol error. + + + + + + + The user performed the drop action. This event does not indicate + acceptance, wl_data_source.cancelled may still be emitted afterwards + if the drop destination does not accept any mime type. + + However, this event might however not be received if the compositor + cancelled the drag-and-drop operation before this event could happen. + + Note that the data_source may still be used in the future and should + not be destroyed here. + + + + + + The drop destination finished interoperating with this data + source, so the client is now free to destroy this data source and + free all associated data. + + If the action used to perform the operation was "move", the + source can now delete the transferred data. + + + + + + This event indicates the action selected by the compositor after + matching the source/destination side actions. Only one action (or + none) will be offered here. + + This event can be emitted multiple times during the drag-and-drop + operation, mainly in response to destination side changes through + wl_data_offer.set_actions, and as the data device enters/leaves + surfaces. + + It is only possible to receive this event after + wl_data_source.dnd_drop_performed if the drag-and-drop operation + ended in an "ask" action, in which case the final wl_data_source.action + event will happen immediately before wl_data_source.dnd_finished. + + Compositors may also change the selected action on the fly, mainly + in response to keyboard modifier changes during the drag-and-drop + operation. + + The most recent action received is always the valid one. The chosen + action may change alongside negotiation (e.g. an "ask" action can turn + into a "move" operation), so the effects of the final action must + always be applied in wl_data_offer.dnd_finished. + + Clients can trigger cursor surface changes from this point, so + they reflect the current action. + + + + + + + + There is one wl_data_device per seat which can be obtained + from the global wl_data_device_manager singleton. + + A wl_data_device provides access to inter-client data transfer + mechanisms such as copy-and-paste and drag-and-drop. + + + + + + + + + This request asks the compositor to start a drag-and-drop + operation on behalf of the client. + + The source argument is the data source that provides the data + for the eventual data transfer. If source is NULL, enter, leave + and motion events are sent only to the client that initiated the + drag and the client is expected to handle the data passing + internally. If source is destroyed, the drag-and-drop session will be + cancelled. + + The origin surface is the surface where the drag originates and + the client must have an active implicit grab that matches the + serial. + + The icon surface is an optional (can be NULL) surface that + provides an icon to be moved around with the cursor. Initially, + the top-left corner of the icon surface is placed at the cursor + hotspot, but subsequent wl_surface.attach request can move the + relative position. Attach requests must be confirmed with + wl_surface.commit as usual. The icon surface is given the role of + a drag-and-drop icon. If the icon surface already has another role, + it raises a protocol error. + + The input region is ignored for wl_surfaces with the role of a + drag-and-drop icon. + + + + + + + + + + This request asks the compositor to set the selection + to the data from the source on behalf of the client. + + To unset the selection, set the source to NULL. + + + + + + + + The data_offer event introduces a new wl_data_offer object, + which will subsequently be used in either the + data_device.enter event (for drag-and-drop) or the + data_device.selection event (for selections). Immediately + following the data_device.data_offer event, the new data_offer + object will send out data_offer.offer events to describe the + mime types it offers. + + + + + + + This event is sent when an active drag-and-drop pointer enters + a surface owned by the client. The position of the pointer at + enter time is provided by the x and y arguments, in surface-local + coordinates. + + + + + + + + + + + This event is sent when the drag-and-drop pointer leaves the + surface and the session ends. The client must destroy the + wl_data_offer introduced at enter time at this point. + + + + + + This event is sent when the drag-and-drop pointer moves within + the currently focused surface. The new position of the pointer + is provided by the x and y arguments, in surface-local + coordinates. + + + + + + + + + The event is sent when a drag-and-drop operation is ended + because the implicit grab is removed. + + The drag-and-drop destination is expected to honor the last action + received through wl_data_offer.action, if the resulting action is + "copy" or "move", the destination can still perform + wl_data_offer.receive requests, and is expected to end all + transfers with a wl_data_offer.finish request. + + If the resulting action is "ask", the action will not be considered + final. The drag-and-drop destination is expected to perform one last + wl_data_offer.set_actions request, or wl_data_offer.destroy in order + to cancel the operation. + + + + + + The selection event is sent out to notify the client of a new + wl_data_offer for the selection for this device. The + data_device.data_offer and the data_offer.offer events are + sent out immediately before this event to introduce the data + offer object. The selection event is sent to a client + immediately before receiving keyboard focus and when a new + selection is set while the client has keyboard focus. The + data_offer is valid until a new data_offer or NULL is received + or until the client loses keyboard focus. Switching surface with + keyboard focus within the same client doesn't mean a new selection + will be sent. The client must destroy the previous selection + data_offer, if any, upon receiving this event. + + + + + + + + + This request destroys the data device. + + + + + + + The wl_data_device_manager is a singleton global object that + provides access to inter-client data transfer mechanisms such as + copy-and-paste and drag-and-drop. These mechanisms are tied to + a wl_seat and this interface lets a client get a wl_data_device + corresponding to a wl_seat. + + Depending on the version bound, the objects created from the bound + wl_data_device_manager object will have different requirements for + functioning properly. See wl_data_source.set_actions, + wl_data_offer.accept and wl_data_offer.finish for details. + + + + + Create a new data source. + + + + + + + Create a new data device for a given seat. + + + + + + + + + + This is a bitmask of the available/preferred actions in a + drag-and-drop operation. + + In the compositor, the selected action is a result of matching the + actions offered by the source and destination sides. "action" events + with a "none" action will be sent to both source and destination if + there is no match. All further checks will effectively happen on + (source actions ∩ destination actions). + + In addition, compositors may also pick different actions in + reaction to key modifiers being pressed. One common design that + is used in major toolkits (and the behavior recommended for + compositors) is: + + - If no modifiers are pressed, the first match (in bit order) + will be used. + - Pressing Shift selects "move", if enabled in the mask. + - Pressing Control selects "copy", if enabled in the mask. + + Behavior beyond that is considered implementation-dependent. + Compositors may for example bind other modifiers (like Alt/Meta) + or drags initiated with other buttons than BTN_LEFT to specific + actions (e.g. "ask"). + + + + + + + + + + + This interface is implemented by servers that provide + desktop-style user interfaces. + + It allows clients to associate a wl_shell_surface with + a basic surface. + + Note! This protocol is deprecated and not intended for production use. + For desktop-style user interfaces, use xdg_shell. Compositors and clients + should not implement this interface. + + + + + + + + + Create a shell surface for an existing surface. This gives + the wl_surface the role of a shell surface. If the wl_surface + already has another role, it raises a protocol error. + + Only one shell surface can be associated with a given surface. + + + + + + + + + An interface that may be implemented by a wl_surface, for + implementations that provide a desktop-style user interface. + + It provides requests to treat surfaces like toplevel, fullscreen + or popup windows, move, resize or maximize them, associate + metadata like title and class, etc. + + On the server side the object is automatically destroyed when + the related wl_surface is destroyed. On the client side, + wl_shell_surface_destroy() must be called before destroying + the wl_surface object. + + + + + A client must respond to a ping event with a pong request or + the client may be deemed unresponsive. + + + + + + + Start a pointer-driven move of the surface. + + This request must be used in response to a button press event. + The server may ignore move requests depending on the state of + the surface (e.g. fullscreen or maximized). + + + + + + + + These values are used to indicate which edge of a surface + is being dragged in a resize operation. The server may + use this information to adapt its behavior, e.g. choose + an appropriate cursor image. + + + + + + + + + + + + + + + Start a pointer-driven resizing of the surface. + + This request must be used in response to a button press event. + The server may ignore resize requests depending on the state of + the surface (e.g. fullscreen or maximized). + + + + + + + + + Map the surface as a toplevel surface. + + A toplevel surface is not fullscreen, maximized or transient. + + + + + + These flags specify details of the expected behaviour + of transient surfaces. Used in the set_transient request. + + + + + + + Map the surface relative to an existing surface. + + The x and y arguments specify the location of the upper left + corner of the surface relative to the upper left corner of the + parent surface, in surface-local coordinates. + + The flags argument controls details of the transient behaviour. + + + + + + + + + + Hints to indicate to the compositor how to deal with a conflict + between the dimensions of the surface and the dimensions of the + output. The compositor is free to ignore this parameter. + + + + + + + + + + Map the surface as a fullscreen surface. + + If an output parameter is given then the surface will be made + fullscreen on that output. If the client does not specify the + output then the compositor will apply its policy - usually + choosing the output on which the surface has the biggest surface + area. + + The client may specify a method to resolve a size conflict + between the output size and the surface size - this is provided + through the method parameter. + + The framerate parameter is used only when the method is set + to "driver", to indicate the preferred framerate. A value of 0 + indicates that the client does not care about framerate. The + framerate is specified in mHz, that is framerate of 60000 is 60Hz. + + A method of "scale" or "driver" implies a scaling operation of + the surface, either via a direct scaling operation or a change of + the output mode. This will override any kind of output scaling, so + that mapping a surface with a buffer size equal to the mode can + fill the screen independent of buffer_scale. + + A method of "fill" means we don't scale up the buffer, however + any output scale is applied. This means that you may run into + an edge case where the application maps a buffer with the same + size of the output mode but buffer_scale 1 (thus making a + surface larger than the output). In this case it is allowed to + downscale the results to fit the screen. + + The compositor must reply to this request with a configure event + with the dimensions for the output on which the surface will + be made fullscreen. + + + + + + + + + Map the surface as a popup. + + A popup surface is a transient surface with an added pointer + grab. + + An existing implicit grab will be changed to owner-events mode, + and the popup grab will continue after the implicit grab ends + (i.e. releasing the mouse button does not cause the popup to + be unmapped). + + The popup grab continues until the window is destroyed or a + mouse button is pressed in any other client's window. A click + in any of the client's surfaces is reported as normal, however, + clicks in other clients' surfaces will be discarded and trigger + the callback. + + The x and y arguments specify the location of the upper left + corner of the surface relative to the upper left corner of the + parent surface, in surface-local coordinates. + + + + + + + + + + + + Map the surface as a maximized surface. + + If an output parameter is given then the surface will be + maximized on that output. If the client does not specify the + output then the compositor will apply its policy - usually + choosing the output on which the surface has the biggest surface + area. + + The compositor will reply with a configure event telling + the expected new surface size. The operation is completed + on the next buffer attach to this surface. + + A maximized surface typically fills the entire output it is + bound to, except for desktop elements such as panels. This is + the main difference between a maximized shell surface and a + fullscreen shell surface. + + The details depend on the compositor implementation. + + + + + + + Set a short title for the surface. + + This string may be used to identify the surface in a task bar, + window list, or other user interface elements provided by the + compositor. + + The string must be encoded in UTF-8. + + + + + + + Set a class for the surface. + + The surface class identifies the general class of applications + to which the surface belongs. A common convention is to use the + file name (or the full path if it is a non-standard location) of + the application's .desktop file as the class. + + + + + + + Ping a client to check if it is receiving events and sending + requests. A client is expected to reply with a pong request. + + + + + + + The configure event asks the client to resize its surface. + + The size is a hint, in the sense that the client is free to + ignore it if it doesn't resize, pick a smaller size (to + satisfy aspect ratio or resize in steps of NxM pixels). + + The edges parameter provides a hint about how the surface + was resized. The client may use this information to decide + how to adjust its content to the new size (e.g. a scrolling + area might adjust its content position to leave the viewable + content unmoved). + + The client is free to dismiss all but the last configure + event it received. + + The width and height arguments specify the size of the window + in surface-local coordinates. + + + + + + + + + The popup_done event is sent out when a popup grab is broken, + that is, when the user clicks a surface that doesn't belong + to the client owning the popup surface. + + + + + + + A surface is a rectangular area that may be displayed on zero + or more outputs, and shown any number of times at the compositor's + discretion. They can present wl_buffers, receive user input, and + define a local coordinate system. + + The size of a surface (and relative positions on it) is described + in surface-local coordinates, which may differ from the buffer + coordinates of the pixel content, in case a buffer_transform + or a buffer_scale is used. + + A surface without a "role" is fairly useless: a compositor does + not know where, when or how to present it. The role is the + purpose of a wl_surface. Examples of roles are a cursor for a + pointer (as set by wl_pointer.set_cursor), a drag icon + (wl_data_device.start_drag), a sub-surface + (wl_subcompositor.get_subsurface), and a window as defined by a + shell protocol (e.g. wl_shell.get_shell_surface). + + A surface can have only one role at a time. Initially a + wl_surface does not have a role. Once a wl_surface is given a + role, it is set permanently for the whole lifetime of the + wl_surface object. Giving the current role again is allowed, + unless explicitly forbidden by the relevant interface + specification. + + Surface roles are given by requests in other interfaces such as + wl_pointer.set_cursor. The request should explicitly mention + that this request gives a role to a wl_surface. Often, this + request also creates a new protocol object that represents the + role and adds additional functionality to wl_surface. When a + client wants to destroy a wl_surface, they must destroy this role + object before the wl_surface, otherwise a defunct_role_object error is + sent. + + Destroying the role object does not remove the role from the + wl_surface, but it may stop the wl_surface from "playing the role". + For instance, if a wl_subsurface object is destroyed, the wl_surface + it was created for will be unmapped and forget its position and + z-order. It is allowed to create a wl_subsurface for the same + wl_surface again, but it is not allowed to use the wl_surface as + a cursor (cursor is a different role than sub-surface, and role + switching is not allowed). + + + + + These errors can be emitted in response to wl_surface requests. + + + + + + + + + + + Deletes the surface and invalidates its object ID. + + + + + + Set a buffer as the content of this surface. + + The new size of the surface is calculated based on the buffer + size transformed by the inverse buffer_transform and the + inverse buffer_scale. This means that at commit time the supplied + buffer size must be an integer multiple of the buffer_scale. If + that's not the case, an invalid_size error is sent. + + The x and y arguments specify the location of the new pending + buffer's upper left corner, relative to the current buffer's upper + left corner, in surface-local coordinates. In other words, the + x and y, combined with the new surface size define in which + directions the surface's size changes. Setting anything other than 0 + as x and y arguments is discouraged, and should instead be replaced + with using the separate wl_surface.offset request. + + When the bound wl_surface version is 5 or higher, passing any + non-zero x or y is a protocol violation, and will result in an + 'invalid_offset' error being raised. The x and y arguments are ignored + and do not change the pending state. To achieve equivalent semantics, + use wl_surface.offset. + + Surface contents are double-buffered state, see wl_surface.commit. + + The initial surface contents are void; there is no content. + wl_surface.attach assigns the given wl_buffer as the pending + wl_buffer. wl_surface.commit makes the pending wl_buffer the new + surface contents, and the size of the surface becomes the size + calculated from the wl_buffer, as described above. After commit, + there is no pending buffer until the next attach. + + Committing a pending wl_buffer allows the compositor to read the + pixels in the wl_buffer. The compositor may access the pixels at + any time after the wl_surface.commit request. When the compositor + will not access the pixels anymore, it will send the + wl_buffer.release event. Only after receiving wl_buffer.release, + the client may reuse the wl_buffer. A wl_buffer that has been + attached and then replaced by another attach instead of committed + will not receive a release event, and is not used by the + compositor. + + If a pending wl_buffer has been committed to more than one wl_surface, + the delivery of wl_buffer.release events becomes undefined. A well + behaved client should not rely on wl_buffer.release events in this + case. Alternatively, a client could create multiple wl_buffer objects + from the same backing storage or use wp_linux_buffer_release. + + Destroying the wl_buffer after wl_buffer.release does not change + the surface contents. Destroying the wl_buffer before wl_buffer.release + is allowed as long as the underlying buffer storage isn't re-used (this + can happen e.g. on client process termination). However, if the client + destroys the wl_buffer before receiving the wl_buffer.release event and + mutates the underlying buffer storage, the surface contents become + undefined immediately. + + If wl_surface.attach is sent with a NULL wl_buffer, the + following wl_surface.commit will remove the surface content. + + + + + + + + + This request is used to describe the regions where the pending + buffer is different from the current surface contents, and where + the surface therefore needs to be repainted. The compositor + ignores the parts of the damage that fall outside of the surface. + + Damage is double-buffered state, see wl_surface.commit. + + The damage rectangle is specified in surface-local coordinates, + where x and y specify the upper left corner of the damage rectangle. + + The initial value for pending damage is empty: no damage. + wl_surface.damage adds pending damage: the new pending damage + is the union of old pending damage and the given rectangle. + + wl_surface.commit assigns pending damage as the current damage, + and clears pending damage. The server will clear the current + damage as it repaints the surface. + + Note! New clients should not use this request. Instead damage can be + posted with wl_surface.damage_buffer which uses buffer coordinates + instead of surface coordinates. + + + + + + + + + + Request a notification when it is a good time to start drawing a new + frame, by creating a frame callback. This is useful for throttling + redrawing operations, and driving animations. + + When a client is animating on a wl_surface, it can use the 'frame' + request to get notified when it is a good time to draw and commit the + next frame of animation. If the client commits an update earlier than + that, it is likely that some updates will not make it to the display, + and the client is wasting resources by drawing too often. + + The frame request will take effect on the next wl_surface.commit. + The notification will only be posted for one frame unless + requested again. For a wl_surface, the notifications are posted in + the order the frame requests were committed. + + The server must send the notifications so that a client + will not send excessive updates, while still allowing + the highest possible update rate for clients that wait for the reply + before drawing again. The server should give some time for the client + to draw and commit after sending the frame callback events to let it + hit the next output refresh. + + A server should avoid signaling the frame callbacks if the + surface is not visible in any way, e.g. the surface is off-screen, + or completely obscured by other opaque surfaces. + + The object returned by this request will be destroyed by the + compositor after the callback is fired and as such the client must not + attempt to use it after that point. + + The callback_data passed in the callback is the current time, in + milliseconds, with an undefined base. + + + + + + + This request sets the region of the surface that contains + opaque content. + + The opaque region is an optimization hint for the compositor + that lets it optimize the redrawing of content behind opaque + regions. Setting an opaque region is not required for correct + behaviour, but marking transparent content as opaque will result + in repaint artifacts. + + The opaque region is specified in surface-local coordinates. + + The compositor ignores the parts of the opaque region that fall + outside of the surface. + + Opaque region is double-buffered state, see wl_surface.commit. + + wl_surface.set_opaque_region changes the pending opaque region. + wl_surface.commit copies the pending region to the current region. + Otherwise, the pending and current regions are never changed. + + The initial value for an opaque region is empty. Setting the pending + opaque region has copy semantics, and the wl_region object can be + destroyed immediately. A NULL wl_region causes the pending opaque + region to be set to empty. + + + + + + + This request sets the region of the surface that can receive + pointer and touch events. + + Input events happening outside of this region will try the next + surface in the server surface stack. The compositor ignores the + parts of the input region that fall outside of the surface. + + The input region is specified in surface-local coordinates. + + Input region is double-buffered state, see wl_surface.commit. + + wl_surface.set_input_region changes the pending input region. + wl_surface.commit copies the pending region to the current region. + Otherwise the pending and current regions are never changed, + except cursor and icon surfaces are special cases, see + wl_pointer.set_cursor and wl_data_device.start_drag. + + The initial value for an input region is infinite. That means the + whole surface will accept input. Setting the pending input region + has copy semantics, and the wl_region object can be destroyed + immediately. A NULL wl_region causes the input region to be set + to infinite. + + + + + + + Surface state (input, opaque, and damage regions, attached buffers, + etc.) is double-buffered. Protocol requests modify the pending state, + as opposed to the current state in use by the compositor. A commit + request atomically applies all pending state, replacing the current + state. After commit, the new pending state is as documented for each + related request. + + On commit, a pending wl_buffer is applied first, and all other state + second. This means that all coordinates in double-buffered state are + relative to the new wl_buffer coming into use, except for + wl_surface.attach itself. If there is no pending wl_buffer, the + coordinates are relative to the current surface contents. + + All requests that need a commit to become effective are documented + to affect double-buffered state. + + Other interfaces may add further double-buffered surface state. + + + + + + This is emitted whenever a surface's creation, movement, or resizing + results in some part of it being within the scanout region of an + output. + + Note that a surface may be overlapping with zero or more outputs. + + + + + + + This is emitted whenever a surface's creation, movement, or resizing + results in it no longer having any part of it within the scanout region + of an output. + + Clients should not use the number of outputs the surface is on for frame + throttling purposes. The surface might be hidden even if no leave event + has been sent, and the compositor might expect new surface content + updates even if no enter event has been sent. The frame event should be + used instead. + + + + + + + + + This request sets an optional transformation on how the compositor + interprets the contents of the buffer attached to the surface. The + accepted values for the transform parameter are the values for + wl_output.transform. + + Buffer transform is double-buffered state, see wl_surface.commit. + + A newly created surface has its buffer transformation set to normal. + + wl_surface.set_buffer_transform changes the pending buffer + transformation. wl_surface.commit copies the pending buffer + transformation to the current one. Otherwise, the pending and current + values are never changed. + + The purpose of this request is to allow clients to render content + according to the output transform, thus permitting the compositor to + use certain optimizations even if the display is rotated. Using + hardware overlays and scanning out a client buffer for fullscreen + surfaces are examples of such optimizations. Those optimizations are + highly dependent on the compositor implementation, so the use of this + request should be considered on a case-by-case basis. + + Note that if the transform value includes 90 or 270 degree rotation, + the width of the buffer will become the surface height and the height + of the buffer will become the surface width. + + If transform is not one of the values from the + wl_output.transform enum the invalid_transform protocol error + is raised. + + + + + + + + + This request sets an optional scaling factor on how the compositor + interprets the contents of the buffer attached to the window. + + Buffer scale is double-buffered state, see wl_surface.commit. + + A newly created surface has its buffer scale set to 1. + + wl_surface.set_buffer_scale changes the pending buffer scale. + wl_surface.commit copies the pending buffer scale to the current one. + Otherwise, the pending and current values are never changed. + + The purpose of this request is to allow clients to supply higher + resolution buffer data for use on high resolution outputs. It is + intended that you pick the same buffer scale as the scale of the + output that the surface is displayed on. This means the compositor + can avoid scaling when rendering the surface on that output. + + Note that if the scale is larger than 1, then you have to attach + a buffer that is larger (by a factor of scale in each dimension) + than the desired surface size. + + If scale is not positive the invalid_scale protocol error is + raised. + + + + + + + + This request is used to describe the regions where the pending + buffer is different from the current surface contents, and where + the surface therefore needs to be repainted. The compositor + ignores the parts of the damage that fall outside of the surface. + + Damage is double-buffered state, see wl_surface.commit. + + The damage rectangle is specified in buffer coordinates, + where x and y specify the upper left corner of the damage rectangle. + + The initial value for pending damage is empty: no damage. + wl_surface.damage_buffer adds pending damage: the new pending + damage is the union of old pending damage and the given rectangle. + + wl_surface.commit assigns pending damage as the current damage, + and clears pending damage. The server will clear the current + damage as it repaints the surface. + + This request differs from wl_surface.damage in only one way - it + takes damage in buffer coordinates instead of surface-local + coordinates. While this generally is more intuitive than surface + coordinates, it is especially desirable when using wp_viewport + or when a drawing library (like EGL) is unaware of buffer scale + and buffer transform. + + Note: Because buffer transformation changes and damage requests may + be interleaved in the protocol stream, it is impossible to determine + the actual mapping between surface and buffer damage until + wl_surface.commit time. Therefore, compositors wishing to take both + kinds of damage into account will have to accumulate damage from the + two requests separately and only transform from one to the other + after receiving the wl_surface.commit. + + + + + + + + + + + + The x and y arguments specify the location of the new pending + buffer's upper left corner, relative to the current buffer's upper + left corner, in surface-local coordinates. In other words, the + x and y, combined with the new surface size define in which + directions the surface's size changes. + + Surface location offset is double-buffered state, see + wl_surface.commit. + + This request is semantically equivalent to and the replaces the x and y + arguments in the wl_surface.attach request in wl_surface versions prior + to 5. See wl_surface.attach for details. + + + + + + + + + + This event indicates the preferred buffer scale for this surface. It is + sent whenever the compositor's preference changes. + + It is intended that scaling aware clients use this event to scale their + content and use wl_surface.set_buffer_scale to indicate the scale they + have rendered with. This allows clients to supply a higher detail + buffer. + + + + + + + This event indicates the preferred buffer transform for this surface. + It is sent whenever the compositor's preference changes. + + It is intended that transform aware clients use this event to apply the + transform to their content and use wl_surface.set_buffer_transform to + indicate the transform they have rendered with. + + + + + + + + A seat is a group of keyboards, pointer and touch devices. This + object is published as a global during start up, or when such a + device is hot plugged. A seat typically has a pointer and + maintains a keyboard focus and a pointer focus. + + + + + This is a bitmask of capabilities this seat has; if a member is + set, then it is present on the seat. + + + + + + + + + These errors can be emitted in response to wl_seat requests. + + + + + + + This is emitted whenever a seat gains or loses the pointer, + keyboard or touch capabilities. The argument is a capability + enum containing the complete set of capabilities this seat has. + + When the pointer capability is added, a client may create a + wl_pointer object using the wl_seat.get_pointer request. This object + will receive pointer events until the capability is removed in the + future. + + When the pointer capability is removed, a client should destroy the + wl_pointer objects associated with the seat where the capability was + removed, using the wl_pointer.release request. No further pointer + events will be received on these objects. + + In some compositors, if a seat regains the pointer capability and a + client has a previously obtained wl_pointer object of version 4 or + less, that object may start sending pointer events again. This + behavior is considered a misinterpretation of the intended behavior + and must not be relied upon by the client. wl_pointer objects of + version 5 or later must not send events if created before the most + recent event notifying the client of an added pointer capability. + + The above behavior also applies to wl_keyboard and wl_touch with the + keyboard and touch capabilities, respectively. + + + + + + + The ID provided will be initialized to the wl_pointer interface + for this seat. + + This request only takes effect if the seat has the pointer + capability, or has had the pointer capability in the past. + It is a protocol violation to issue this request on a seat that has + never had the pointer capability. The missing_capability error will + be sent in this case. + + + + + + + The ID provided will be initialized to the wl_keyboard interface + for this seat. + + This request only takes effect if the seat has the keyboard + capability, or has had the keyboard capability in the past. + It is a protocol violation to issue this request on a seat that has + never had the keyboard capability. The missing_capability error will + be sent in this case. + + + + + + + The ID provided will be initialized to the wl_touch interface + for this seat. + + This request only takes effect if the seat has the touch + capability, or has had the touch capability in the past. + It is a protocol violation to issue this request on a seat that has + never had the touch capability. The missing_capability error will + be sent in this case. + + + + + + + + + In a multi-seat configuration the seat name can be used by clients to + help identify which physical devices the seat represents. + + The seat name is a UTF-8 string with no convention defined for its + contents. Each name is unique among all wl_seat globals. The name is + only guaranteed to be unique for the current compositor instance. + + The same seat names are used for all clients. Thus, the name can be + shared across processes to refer to a specific wl_seat global. + + The name event is sent after binding to the seat global. This event is + only sent once per seat object, and the name does not change over the + lifetime of the wl_seat global. + + Compositors may re-use the same seat name if the wl_seat global is + destroyed and re-created later. + + + + + + + + + Using this request a client can tell the server that it is not going to + use the seat object anymore. + + + + + + + + The wl_pointer interface represents one or more input devices, + such as mice, which control the pointer location and pointer_focus + of a seat. + + The wl_pointer interface generates motion, enter and leave + events for the surfaces that the pointer is located over, + and button and axis events for button presses, button releases + and scrolling. + + + + + + + + + Set the pointer surface, i.e., the surface that contains the + pointer image (cursor). This request gives the surface the role + of a cursor. If the surface already has another role, it raises + a protocol error. + + The cursor actually changes only if the pointer + focus for this device is one of the requesting client's surfaces + or the surface parameter is the current pointer surface. If + there was a previous surface set with this request it is + replaced. If surface is NULL, the pointer image is hidden. + + The parameters hotspot_x and hotspot_y define the position of + the pointer surface relative to the pointer location. Its + top-left corner is always at (x, y) - (hotspot_x, hotspot_y), + where (x, y) are the coordinates of the pointer location, in + surface-local coordinates. + + On surface.attach requests to the pointer surface, hotspot_x + and hotspot_y are decremented by the x and y parameters + passed to the request. Attach must be confirmed by + wl_surface.commit as usual. + + The hotspot can also be updated by passing the currently set + pointer surface to this request with new values for hotspot_x + and hotspot_y. + + The input region is ignored for wl_surfaces with the role of + a cursor. When the use as a cursor ends, the wl_surface is + unmapped. + + The serial parameter must match the latest wl_pointer.enter + serial number sent to the client. Otherwise the request will be + ignored. + + + + + + + + + + Notification that this seat's pointer is focused on a certain + surface. + + When a seat's focus enters a surface, the pointer image + is undefined and a client should respond to this event by setting + an appropriate pointer image with the set_cursor request. + + + + + + + + + + Notification that this seat's pointer is no longer focused on + a certain surface. + + The leave notification is sent before the enter notification + for the new focus. + + + + + + + + Notification of pointer location change. The arguments + surface_x and surface_y are the location relative to the + focused surface. + + + + + + + + + Describes the physical state of a button that produced the button + event. + + + + + + + + Mouse button click and release notifications. + + The location of the click is given by the last motion or + enter event. + The time argument is a timestamp with millisecond + granularity, with an undefined base. + + The button is a button code as defined in the Linux kernel's + linux/input-event-codes.h header file, e.g. BTN_LEFT. + + Any 16-bit button code value is reserved for future additions to the + kernel's event code list. All other button codes above 0xFFFF are + currently undefined but may be used in future versions of this + protocol. + + + + + + + + + + Describes the axis types of scroll events. + + + + + + + + Scroll and other axis notifications. + + For scroll events (vertical and horizontal scroll axes), the + value parameter is the length of a vector along the specified + axis in a coordinate space identical to those of motion events, + representing a relative movement along the specified axis. + + For devices that support movements non-parallel to axes multiple + axis events will be emitted. + + When applicable, for example for touch pads, the server can + choose to emit scroll events where the motion vector is + equivalent to a motion event vector. + + When applicable, a client can transform its content relative to the + scroll distance. + + + + + + + + + + + Using this request a client can tell the server that it is not going to + use the pointer object anymore. + + This request destroys the pointer proxy object, so clients must not call + wl_pointer_destroy() after using this request. + + + + + + + + Indicates the end of a set of events that logically belong together. + A client is expected to accumulate the data in all events within the + frame before proceeding. + + All wl_pointer events before a wl_pointer.frame event belong + logically together. For example, in a diagonal scroll motion the + compositor will send an optional wl_pointer.axis_source event, two + wl_pointer.axis events (horizontal and vertical) and finally a + wl_pointer.frame event. The client may use this information to + calculate a diagonal vector for scrolling. + + When multiple wl_pointer.axis events occur within the same frame, + the motion vector is the combined motion of all events. + When a wl_pointer.axis and a wl_pointer.axis_stop event occur within + the same frame, this indicates that axis movement in one axis has + stopped but continues in the other axis. + When multiple wl_pointer.axis_stop events occur within the same + frame, this indicates that these axes stopped in the same instance. + + A wl_pointer.frame event is sent for every logical event group, + even if the group only contains a single wl_pointer event. + Specifically, a client may get a sequence: motion, frame, button, + frame, axis, frame, axis_stop, frame. + + The wl_pointer.enter and wl_pointer.leave events are logical events + generated by the compositor and not the hardware. These events are + also grouped by a wl_pointer.frame. When a pointer moves from one + surface to another, a compositor should group the + wl_pointer.leave event within the same wl_pointer.frame. + However, a client must not rely on wl_pointer.leave and + wl_pointer.enter being in the same wl_pointer.frame. + Compositor-specific policies may require the wl_pointer.leave and + wl_pointer.enter event being split across multiple wl_pointer.frame + groups. + + + + + + Describes the source types for axis events. This indicates to the + client how an axis event was physically generated; a client may + adjust the user interface accordingly. For example, scroll events + from a "finger" source may be in a smooth coordinate space with + kinetic scrolling whereas a "wheel" source may be in discrete steps + of a number of lines. + + The "continuous" axis source is a device generating events in a + continuous coordinate space, but using something other than a + finger. One example for this source is button-based scrolling where + the vertical motion of a device is converted to scroll events while + a button is held down. + + The "wheel tilt" axis source indicates that the actual device is a + wheel but the scroll event is not caused by a rotation but a + (usually sideways) tilt of the wheel. + + + + + + + + + + Source information for scroll and other axes. + + This event does not occur on its own. It is sent before a + wl_pointer.frame event and carries the source information for + all events within that frame. + + The source specifies how this event was generated. If the source is + wl_pointer.axis_source.finger, a wl_pointer.axis_stop event will be + sent when the user lifts the finger off the device. + + If the source is wl_pointer.axis_source.wheel, + wl_pointer.axis_source.wheel_tilt or + wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event may + or may not be sent. Whether a compositor sends an axis_stop event + for these sources is hardware-specific and implementation-dependent; + clients must not rely on receiving an axis_stop event for these + scroll sources and should treat scroll sequences from these scroll + sources as unterminated by default. + + This event is optional. If the source is unknown for a particular + axis event sequence, no event is sent. + Only one wl_pointer.axis_source event is permitted per frame. + + The order of wl_pointer.axis_discrete and wl_pointer.axis_source is + not guaranteed. + + + + + + + Stop notification for scroll and other axes. + + For some wl_pointer.axis_source types, a wl_pointer.axis_stop event + is sent to notify a client that the axis sequence has terminated. + This enables the client to implement kinetic scrolling. + See the wl_pointer.axis_source documentation for information on when + this event may be generated. + + Any wl_pointer.axis events with the same axis_source after this + event should be considered as the start of a new axis motion. + + The timestamp is to be interpreted identical to the timestamp in the + wl_pointer.axis event. The timestamp value may be the same as a + preceding wl_pointer.axis event. + + + + + + + + Discrete step information for scroll and other axes. + + This event carries the axis value of the wl_pointer.axis event in + discrete steps (e.g. mouse wheel clicks). + + This event is deprecated with wl_pointer version 8 - this event is not + sent to clients supporting version 8 or later. + + This event does not occur on its own, it is coupled with a + wl_pointer.axis event that represents this axis value on a + continuous scale. The protocol guarantees that each axis_discrete + event is always followed by exactly one axis event with the same + axis number within the same wl_pointer.frame. Note that the protocol + allows for other events to occur between the axis_discrete and + its coupled axis event, including other axis_discrete or axis + events. A wl_pointer.frame must not contain more than one axis_discrete + event per axis type. + + This event is optional; continuous scrolling devices + like two-finger scrolling on touchpads do not have discrete + steps and do not generate this event. + + The discrete value carries the directional information. e.g. a value + of -2 is two steps towards the negative direction of this axis. + + The axis number is identical to the axis number in the associated + axis event. + + The order of wl_pointer.axis_discrete and wl_pointer.axis_source is + not guaranteed. + + + + + + + + Discrete high-resolution scroll information. + + This event carries high-resolution wheel scroll information, + with each multiple of 120 representing one logical scroll step + (a wheel detent). For example, an axis_value120 of 30 is one quarter of + a logical scroll step in the positive direction, a value120 of + -240 are two logical scroll steps in the negative direction within the + same hardware event. + Clients that rely on discrete scrolling should accumulate the + value120 to multiples of 120 before processing the event. + + The value120 must not be zero. + + This event replaces the wl_pointer.axis_discrete event in clients + supporting wl_pointer version 8 or later. + + Where a wl_pointer.axis_source event occurs in the same + wl_pointer.frame, the axis source applies to this event. + + The order of wl_pointer.axis_value120 and wl_pointer.axis_source is + not guaranteed. + + + + + + + + + + This specifies the direction of the physical motion that caused a + wl_pointer.axis event, relative to the wl_pointer.axis direction. + + + + + + + + Relative directional information of the entity causing the axis + motion. + + For a wl_pointer.axis event, the wl_pointer.axis_relative_direction + event specifies the movement direction of the entity causing the + wl_pointer.axis event. For example: + - if a user's fingers on a touchpad move down and this + causes a wl_pointer.axis vertical_scroll down event, the physical + direction is 'identical' + - if a user's fingers on a touchpad move down and this causes a + wl_pointer.axis vertical_scroll up scroll up event ('natural + scrolling'), the physical direction is 'inverted'. + + A client may use this information to adjust scroll motion of + components. Specifically, enabling natural scrolling causes the + content to change direction compared to traditional scrolling. + Some widgets like volume control sliders should usually match the + physical direction regardless of whether natural scrolling is + active. This event enables clients to match the scroll direction of + a widget to the physical direction. + + This event does not occur on its own, it is coupled with a + wl_pointer.axis event that represents this axis value. + The protocol guarantees that each axis_relative_direction event is + always followed by exactly one axis event with the same + axis number within the same wl_pointer.frame. Note that the protocol + allows for other events to occur between the axis_relative_direction + and its coupled axis event. + + The axis number is identical to the axis number in the associated + axis event. + + The order of wl_pointer.axis_relative_direction, + wl_pointer.axis_discrete and wl_pointer.axis_source is not + guaranteed. + + + + + + + + + The wl_keyboard interface represents one or more keyboards + associated with a seat. + + + + + This specifies the format of the keymap provided to the + client with the wl_keyboard.keymap event. + + + + + + + + This event provides a file descriptor to the client which can be + memory-mapped in read-only mode to provide a keyboard mapping + description. + + From version 7 onwards, the fd must be mapped with MAP_PRIVATE by + the recipient, as MAP_SHARED may fail. + + + + + + + + + Notification that this seat's keyboard focus is on a certain + surface. + + The compositor must send the wl_keyboard.modifiers event after this + event. + + + + + + + + + Notification that this seat's keyboard focus is no longer on + a certain surface. + + The leave notification is sent before the enter notification + for the new focus. + + After this event client must assume that all keys, including modifiers, + are lifted and also it must stop key repeating if there's some going on. + + + + + + + + Describes the physical state of a key that produced the key event. + + + + + + + + A key was pressed or released. + The time argument is a timestamp with millisecond + granularity, with an undefined base. + + The key is a platform-specific key code that can be interpreted + by feeding it to the keyboard mapping (see the keymap event). + + If this event produces a change in modifiers, then the resulting + wl_keyboard.modifiers event must be sent after this event. + + + + + + + + + + Notifies clients that the modifier and/or group state has + changed, and it should update its local state. + + + + + + + + + + + + + + + + + + + Informs the client about the keyboard's repeat rate and delay. + + This event is sent as soon as the wl_keyboard object has been created, + and is guaranteed to be received by the client before any key press + event. + + Negative values for either rate or delay are illegal. A rate of zero + will disable any repeating (regardless of the value of delay). + + This event can be sent later on as well with a new value if necessary, + so clients should continue listening for the event past the creation + of wl_keyboard. + + + + + + + + + The wl_touch interface represents a touchscreen + associated with a seat. + + Touch interactions can consist of one or more contacts. + For each contact, a series of events is generated, starting + with a down event, followed by zero or more motion events, + and ending with an up event. Events relating to the same + contact point can be identified by the ID of the sequence. + + + + + A new touch point has appeared on the surface. This touch point is + assigned a unique ID. Future events from this touch point reference + this ID. The ID ceases to be valid after a touch up event and may be + reused in the future. + + + + + + + + + + + + The touch point has disappeared. No further events will be sent for + this touch point and the touch point's ID is released and may be + reused in a future touch down event. + + + + + + + + + A touch point has changed coordinates. + + + + + + + + + + Indicates the end of a set of events that logically belong together. + A client is expected to accumulate the data in all events within the + frame before proceeding. + + A wl_touch.frame terminates at least one event but otherwise no + guarantee is provided about the set of events within a frame. A client + must assume that any state not updated in a frame is unchanged from the + previously known state. + + + + + + Sent if the compositor decides the touch stream is a global + gesture. No further events are sent to the clients from that + particular gesture. Touch cancellation applies to all touch points + currently active on this client's surface. The client is + responsible for finalizing the touch points, future touch points on + this surface may reuse the touch point ID. + + + + + + + + + + + + + + Sent when a touchpoint has changed its shape. + + This event does not occur on its own. It is sent before a + wl_touch.frame event and carries the new shape information for + any previously reported, or new touch points of that frame. + + Other events describing the touch point such as wl_touch.down, + wl_touch.motion or wl_touch.orientation may be sent within the + same wl_touch.frame. A client should treat these events as a single + logical touch point update. The order of wl_touch.shape, + wl_touch.orientation and wl_touch.motion is not guaranteed. + A wl_touch.down event is guaranteed to occur before the first + wl_touch.shape event for this touch ID but both events may occur within + the same wl_touch.frame. + + A touchpoint shape is approximated by an ellipse through the major and + minor axis length. The major axis length describes the longer diameter + of the ellipse, while the minor axis length describes the shorter + diameter. Major and minor are orthogonal and both are specified in + surface-local coordinates. The center of the ellipse is always at the + touchpoint location as reported by wl_touch.down or wl_touch.move. + + This event is only sent by the compositor if the touch device supports + shape reports. The client has to make reasonable assumptions about the + shape if it did not receive this event. + + + + + + + + + Sent when a touchpoint has changed its orientation. + + This event does not occur on its own. It is sent before a + wl_touch.frame event and carries the new shape information for + any previously reported, or new touch points of that frame. + + Other events describing the touch point such as wl_touch.down, + wl_touch.motion or wl_touch.shape may be sent within the + same wl_touch.frame. A client should treat these events as a single + logical touch point update. The order of wl_touch.shape, + wl_touch.orientation and wl_touch.motion is not guaranteed. + A wl_touch.down event is guaranteed to occur before the first + wl_touch.orientation event for this touch ID but both events may occur + within the same wl_touch.frame. + + The orientation describes the clockwise angle of a touchpoint's major + axis to the positive surface y-axis and is normalized to the -180 to + +180 degree range. The granularity of orientation depends on the touch + device, some devices only support binary rotation values between 0 and + 90 degrees. + + This event is only sent by the compositor if the touch device supports + orientation reports. + + + + + + + + + An output describes part of the compositor geometry. The + compositor works in the 'compositor coordinate system' and an + output corresponds to a rectangular area in that space that is + actually visible. This typically corresponds to a monitor that + displays part of the compositor space. This object is published + as global during start up, or when a monitor is hotplugged. + + + + + This enumeration describes how the physical + pixels on an output are laid out. + + + + + + + + + + + + This describes the transform that a compositor will apply to a + surface to compensate for the rotation or mirroring of an + output device. + + The flipped values correspond to an initial flip around a + vertical axis followed by rotation. + + The purpose is mainly to allow clients to render accordingly and + tell the compositor, so that for fullscreen surfaces, the + compositor will still be able to scan out directly from client + surfaces. + + + + + + + + + + + + + + The geometry event describes geometric properties of the output. + The event is sent when binding to the output object and whenever + any of the properties change. + + The physical size can be set to zero if it doesn't make sense for this + output (e.g. for projectors or virtual outputs). + + The geometry event will be followed by a done event (starting from + version 2). + + Note: wl_output only advertises partial information about the output + position and identification. Some compositors, for instance those not + implementing a desktop-style output layout or those exposing virtual + outputs, might fake this information. Instead of using x and y, clients + should use xdg_output.logical_position. Instead of using make and model, + clients should use name and description. + + + + + + + + + + + + + + These flags describe properties of an output mode. + They are used in the flags bitfield of the mode event. + + + + + + + + The mode event describes an available mode for the output. + + The event is sent when binding to the output object and there + will always be one mode, the current mode. The event is sent + again if an output changes mode, for the mode that is now + current. In other words, the current mode is always the last + mode that was received with the current flag set. + + Non-current modes are deprecated. A compositor can decide to only + advertise the current mode and never send other modes. Clients + should not rely on non-current modes. + + The size of a mode is given in physical hardware units of + the output device. This is not necessarily the same as + the output size in the global compositor space. For instance, + the output may be scaled, as described in wl_output.scale, + or transformed, as described in wl_output.transform. Clients + willing to retrieve the output size in the global compositor + space should use xdg_output.logical_size instead. + + The vertical refresh rate can be set to zero if it doesn't make + sense for this output (e.g. for virtual outputs). + + The mode event will be followed by a done event (starting from + version 2). + + Clients should not use the refresh rate to schedule frames. Instead, + they should use the wl_surface.frame event or the presentation-time + protocol. + + Note: this information is not always meaningful for all outputs. Some + compositors, such as those exposing virtual outputs, might fake the + refresh rate or the size. + + + + + + + + + + + + This event is sent after all other properties have been + sent after binding to the output object and after any + other property changes done after that. This allows + changes to the output properties to be seen as + atomic, even if they happen via multiple events. + + + + + + This event contains scaling geometry information + that is not in the geometry event. It may be sent after + binding the output object or if the output scale changes + later. If it is not sent, the client should assume a + scale of 1. + + A scale larger than 1 means that the compositor will + automatically scale surface buffers by this amount + when rendering. This is used for very high resolution + displays where applications rendering at the native + resolution would be too small to be legible. + + It is intended that scaling aware clients track the + current output of a surface, and if it is on a scaled + output it should use wl_surface.set_buffer_scale with + the scale of the output. That way the compositor can + avoid scaling the surface, and the client can supply + a higher detail image. + + The scale event will be followed by a done event. + + + + + + + + + Using this request a client can tell the server that it is not going to + use the output object anymore. + + + + + + + + Many compositors will assign user-friendly names to their outputs, show + them to the user, allow the user to refer to an output, etc. The client + may wish to know this name as well to offer the user similar behaviors. + + The name is a UTF-8 string with no convention defined for its contents. + Each name is unique among all wl_output globals. The name is only + guaranteed to be unique for the compositor instance. + + The same output name is used for all clients for a given wl_output + global. Thus, the name can be shared across processes to refer to a + specific wl_output global. + + The name is not guaranteed to be persistent across sessions, thus cannot + be used to reliably identify an output in e.g. configuration files. + + Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. However, do + not assume that the name is a reflection of an underlying DRM connector, + X11 connection, etc. + + The name event is sent after binding the output object. This event is + only sent once per output object, and the name does not change over the + lifetime of the wl_output global. + + Compositors may re-use the same output name if the wl_output global is + destroyed and re-created later. Compositors should avoid re-using the + same name if possible. + + The name event will be followed by a done event. + + + + + + + Many compositors can produce human-readable descriptions of their + outputs. The client may wish to know this description as well, e.g. for + output selection purposes. + + The description is a UTF-8 string with no convention defined for its + contents. The description is not guaranteed to be unique among all + wl_output globals. Examples might include 'Foocorp 11" Display' or + 'Virtual X11 output via :1'. + + The description event is sent after binding the output object and + whenever the description changes. The description is optional, and may + not be sent at all. + + The description event will be followed by a done event. + + + + + + + + A region object describes an area. + + Region objects are used to describe the opaque and input + regions of a surface. + + + + + Destroy the region. This will invalidate the object ID. + + + + + + Add the specified rectangle to the region. + + + + + + + + + + Subtract the specified rectangle from the region. + + + + + + + + + + + The global interface exposing sub-surface compositing capabilities. + A wl_surface, that has sub-surfaces associated, is called the + parent surface. Sub-surfaces can be arbitrarily nested and create + a tree of sub-surfaces. + + The root surface in a tree of sub-surfaces is the main + surface. The main surface cannot be a sub-surface, because + sub-surfaces must always have a parent. + + A main surface with its sub-surfaces forms a (compound) window. + For window management purposes, this set of wl_surface objects is + to be considered as a single window, and it should also behave as + such. + + The aim of sub-surfaces is to offload some of the compositing work + within a window from clients to the compositor. A prime example is + a video player with decorations and video in separate wl_surface + objects. This should allow the compositor to pass YUV video buffer + processing to dedicated overlay hardware when possible. + + + + + Informs the server that the client will not be using this + protocol object anymore. This does not affect any other + objects, wl_subsurface objects included. + + + + + + + + + + + Create a sub-surface interface for the given surface, and + associate it with the given parent surface. This turns a + plain wl_surface into a sub-surface. + + The to-be sub-surface must not already have another role, and it + must not have an existing wl_subsurface object. Otherwise the + bad_surface protocol error is raised. + + Adding sub-surfaces to a parent is a double-buffered operation on the + parent (see wl_surface.commit). The effect of adding a sub-surface + becomes visible on the next time the state of the parent surface is + applied. + + The parent surface must not be one of the child surface's descendants, + and the parent must be different from the child surface, otherwise the + bad_parent protocol error is raised. + + This request modifies the behaviour of wl_surface.commit request on + the sub-surface, see the documentation on wl_subsurface interface. + + + + + + + + + + An additional interface to a wl_surface object, which has been + made a sub-surface. A sub-surface has one parent surface. A + sub-surface's size and position are not limited to that of the parent. + Particularly, a sub-surface is not automatically clipped to its + parent's area. + + A sub-surface becomes mapped, when a non-NULL wl_buffer is applied + and the parent surface is mapped. The order of which one happens + first is irrelevant. A sub-surface is hidden if the parent becomes + hidden, or if a NULL wl_buffer is applied. These rules apply + recursively through the tree of surfaces. + + The behaviour of a wl_surface.commit request on a sub-surface + depends on the sub-surface's mode. The possible modes are + synchronized and desynchronized, see methods + wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized + mode caches the wl_surface state to be applied when the parent's + state gets applied, and desynchronized mode applies the pending + wl_surface state directly. A sub-surface is initially in the + synchronized mode. + + Sub-surfaces also have another kind of state, which is managed by + wl_subsurface requests, as opposed to wl_surface requests. This + state includes the sub-surface position relative to the parent + surface (wl_subsurface.set_position), and the stacking order of + the parent and its sub-surfaces (wl_subsurface.place_above and + .place_below). This state is applied when the parent surface's + wl_surface state is applied, regardless of the sub-surface's mode. + As the exception, set_sync and set_desync are effective immediately. + + The main surface can be thought to be always in desynchronized mode, + since it does not have a parent in the sub-surfaces sense. + + Even if a sub-surface is in desynchronized mode, it will behave as + in synchronized mode, if its parent surface behaves as in + synchronized mode. This rule is applied recursively throughout the + tree of surfaces. This means, that one can set a sub-surface into + synchronized mode, and then assume that all its child and grand-child + sub-surfaces are synchronized, too, without explicitly setting them. + + Destroying a sub-surface takes effect immediately. If you need to + synchronize the removal of a sub-surface to the parent surface update, + unmap the sub-surface first by attaching a NULL wl_buffer, update parent, + and then destroy the sub-surface. + + If the parent wl_surface object is destroyed, the sub-surface is + unmapped. + + + + + The sub-surface interface is removed from the wl_surface object + that was turned into a sub-surface with a + wl_subcompositor.get_subsurface request. The wl_surface's association + to the parent is deleted. The wl_surface is unmapped immediately. + + + + + + + + + + This schedules a sub-surface position change. + The sub-surface will be moved so that its origin (top left + corner pixel) will be at the location x, y of the parent surface + coordinate system. The coordinates are not restricted to the parent + surface area. Negative values are allowed. + + The scheduled coordinates will take effect whenever the state of the + parent surface is applied. When this happens depends on whether the + parent surface is in synchronized mode or not. See + wl_subsurface.set_sync and wl_subsurface.set_desync for details. + + If more than one set_position request is invoked by the client before + the commit of the parent surface, the position of a new request always + replaces the scheduled position from any previous request. + + The initial position is 0, 0. + + + + + + + + This sub-surface is taken from the stack, and put back just + above the reference surface, changing the z-order of the sub-surfaces. + The reference surface must be one of the sibling surfaces, or the + parent surface. Using any other surface, including this sub-surface, + will cause a protocol error. + + The z-order is double-buffered. Requests are handled in order and + applied immediately to a pending state. The final pending state is + copied to the active state the next time the state of the parent + surface is applied. When this happens depends on whether the parent + surface is in synchronized mode or not. See wl_subsurface.set_sync and + wl_subsurface.set_desync for details. + + A new sub-surface is initially added as the top-most in the stack + of its siblings and parent. + + + + + + + The sub-surface is placed just below the reference surface. + See wl_subsurface.place_above. + + + + + + + Change the commit behaviour of the sub-surface to synchronized + mode, also described as the parent dependent mode. + + In synchronized mode, wl_surface.commit on a sub-surface will + accumulate the committed state in a cache, but the state will + not be applied and hence will not change the compositor output. + The cached state is applied to the sub-surface immediately after + the parent surface's state is applied. This ensures atomic + updates of the parent and all its synchronized sub-surfaces. + Applying the cached state will invalidate the cache, so further + parent surface commits do not (re-)apply old state. + + See wl_subsurface for the recursive effect of this mode. + + + + + + Change the commit behaviour of the sub-surface to desynchronized + mode, also described as independent or freely running mode. + + In desynchronized mode, wl_surface.commit on a sub-surface will + apply the pending state directly, without caching, as happens + normally with a wl_surface. Calling wl_surface.commit on the + parent surface has no effect on the sub-surface's wl_surface + state. This mode allows a sub-surface to be updated on its own. + + If cached state exists when wl_surface.commit is called in + desynchronized mode, the pending state is added to the cached + state, and applied as a whole. This invalidates the cache. + + Note: even if a sub-surface is set to desynchronized, a parent + sub-surface may override it to behave as synchronized. For details, + see wl_subsurface. + + If a surface's parent surface behaves as desynchronized, then + the cached state is applied on set_desync. + + + + + diff --git a/deps/wayland/xdg-decoration-unstable-v1.xml b/deps/wayland/xdg-decoration-unstable-v1.xml new file mode 100644 index 00000000..e5967751 --- /dev/null +++ b/deps/wayland/xdg-decoration-unstable-v1.xml @@ -0,0 +1,156 @@ + + + + Copyright © 2018 Simon Ser + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + + This interface allows a compositor to announce support for server-side + decorations. + + A window decoration is a set of window controls as deemed appropriate by + the party managing them, such as user interface components used to move, + resize and change a window's state. + + A client can use this protocol to request being decorated by a supporting + compositor. + + If compositor and client do not negotiate the use of a server-side + decoration using this protocol, clients continue to self-decorate as they + see fit. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + + + + + Destroy the decoration manager. This doesn't destroy objects created + with the manager. + + + + + + Create a new decoration object associated with the given toplevel. + + Creating an xdg_toplevel_decoration from an xdg_toplevel which has a + buffer attached or committed is a client error, and any attempts by a + client to attach or manipulate a buffer prior to the first + xdg_toplevel_decoration.configure event must also be treated as + errors. + + + + + + + + + The decoration object allows the compositor to toggle server-side window + decorations for a toplevel surface. The client can request to switch to + another mode. + + The xdg_toplevel_decoration object must be destroyed before its + xdg_toplevel. + + + + + + + + + + + Switch back to a mode without any server-side decorations at the next + commit. + + + + + + These values describe window decoration modes. + + + + + + + + Set the toplevel surface decoration mode. This informs the compositor + that the client prefers the provided decoration mode. + + After requesting a decoration mode, the compositor will respond by + emitting an xdg_surface.configure event. The client should then update + its content, drawing it without decorations if the received mode is + server-side decorations. The client must also acknowledge the configure + when committing the new content (see xdg_surface.ack_configure). + + The compositor can decide not to use the client's mode and enforce a + different mode instead. + + Clients whose decoration mode depend on the xdg_toplevel state may send + a set_mode request in response to an xdg_surface.configure event and wait + for the next xdg_surface.configure event to prevent unwanted state. + Such clients are responsible for preventing configure loops and must + make sure not to send multiple successive set_mode requests with the + same decoration mode. + + + + + + + Unset the toplevel surface decoration mode. This informs the compositor + that the client doesn't prefer a particular decoration mode. + + This request has the same semantics as set_mode. + + + + + + The configure event asks the client to change its decoration mode. The + configured state should not be applied immediately. Clients must send an + ack_configure in response to this event. See xdg_surface.configure and + xdg_surface.ack_configure for details. + + A configure event can be sent at any time. The specified mode must be + obeyed by the client. + + + + + diff --git a/deps/wayland/xdg-shell.xml b/deps/wayland/xdg-shell.xml new file mode 100644 index 00000000..777eaa74 --- /dev/null +++ b/deps/wayland/xdg-shell.xml @@ -0,0 +1,1370 @@ + + + + + Copyright © 2008-2013 Kristian Høgsberg + Copyright © 2013 Rafael Antognolli + Copyright © 2013 Jasper St. Pierre + Copyright © 2010-2013 Intel Corporation + Copyright © 2015-2017 Samsung Electronics Co., Ltd + Copyright © 2015-2017 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + + The xdg_wm_base interface is exposed as a global object enabling clients + to turn their wl_surfaces into windows in a desktop environment. It + defines the basic functionality needed for clients and the compositor to + create windows that can be dragged, resized, maximized, etc, as well as + creating transient windows such as popup menus. + + + + + + + + + + + + + + + Destroy this xdg_wm_base object. + + Destroying a bound xdg_wm_base object while there are surfaces + still alive created by this xdg_wm_base object instance is illegal + and will result in a defunct_surfaces error. + + + + + + Create a positioner object. A positioner object is used to position + surfaces relative to some parent surface. See the interface description + and xdg_surface.get_popup for details. + + + + + + + This creates an xdg_surface for the given surface. While xdg_surface + itself is not a role, the corresponding surface may only be assigned + a role extending xdg_surface, such as xdg_toplevel or xdg_popup. It is + illegal to create an xdg_surface for a wl_surface which already has an + assigned role and this will result in a role error. + + This creates an xdg_surface for the given surface. An xdg_surface is + used as basis to define a role to a given surface, such as xdg_toplevel + or xdg_popup. It also manages functionality shared between xdg_surface + based surface roles. + + See the documentation of xdg_surface for more details about what an + xdg_surface is and how it is used. + + + + + + + + A client must respond to a ping event with a pong request or + the client may be deemed unresponsive. See xdg_wm_base.ping + and xdg_wm_base.error.unresponsive. + + + + + + + The ping event asks the client if it's still alive. Pass the + serial specified in the event back to the compositor by sending + a "pong" request back with the specified serial. See xdg_wm_base.pong. + + Compositors can use this to determine if the client is still + alive. It's unspecified what will happen if the client doesn't + respond to the ping request, or in what timeframe. Clients should + try to respond in a reasonable amount of time. The “unresponsive” + error is provided for compositors that wish to disconnect unresponsive + clients. + + A compositor is free to ping in any way it wants, but a client must + always respond to any xdg_wm_base object it created. + + + + + + + + The xdg_positioner provides a collection of rules for the placement of a + child surface relative to a parent surface. Rules can be defined to ensure + the child surface remains within the visible area's borders, and to + specify how the child surface changes its position, such as sliding along + an axis, or flipping around a rectangle. These positioner-created rules are + constrained by the requirement that a child surface must intersect with or + be at least partially adjacent to its parent surface. + + See the various requests for details about possible rules. + + At the time of the request, the compositor makes a copy of the rules + specified by the xdg_positioner. Thus, after the request is complete the + xdg_positioner object can be destroyed or reused; further changes to the + object will have no effect on previous usages. + + For an xdg_positioner object to be considered complete, it must have a + non-zero size set by set_size, and a non-zero anchor rectangle set by + set_anchor_rect. Passing an incomplete xdg_positioner object when + positioning a surface raises an invalid_positioner error. + + + + + + + + + Notify the compositor that the xdg_positioner will no longer be used. + + + + + + Set the size of the surface that is to be positioned with the positioner + object. The size is in surface-local coordinates and corresponds to the + window geometry. See xdg_surface.set_window_geometry. + + If a zero or negative size is set the invalid_input error is raised. + + + + + + + + Specify the anchor rectangle within the parent surface that the child + surface will be placed relative to. The rectangle is relative to the + window geometry as defined by xdg_surface.set_window_geometry of the + parent surface. + + When the xdg_positioner object is used to position a child surface, the + anchor rectangle may not extend outside the window geometry of the + positioned child's parent surface. + + If a negative size is set the invalid_input error is raised. + + + + + + + + + + + + + + + + + + + + + + Defines the anchor point for the anchor rectangle. The specified anchor + is used derive an anchor point that the child surface will be + positioned relative to. If a corner anchor is set (e.g. 'top_left' or + 'bottom_right'), the anchor point will be at the specified corner; + otherwise, the derived anchor point will be centered on the specified + edge, or in the center of the anchor rectangle if no edge is specified. + + + + + + + + + + + + + + + + + + + Defines in what direction a surface should be positioned, relative to + the anchor point of the parent surface. If a corner gravity is + specified (e.g. 'bottom_right' or 'top_left'), then the child surface + will be placed towards the specified gravity; otherwise, the child + surface will be centered over the anchor point on any axis that had no + gravity specified. If the gravity is not in the ‘gravity’ enum, an + invalid_input error is raised. + + + + + + + The constraint adjustment value define ways the compositor will adjust + the position of the surface, if the unadjusted position would result + in the surface being partly constrained. + + Whether a surface is considered 'constrained' is left to the compositor + to determine. For example, the surface may be partly outside the + compositor's defined 'work area', thus necessitating the child surface's + position be adjusted until it is entirely inside the work area. + + The adjustments can be combined, according to a defined precedence: 1) + Flip, 2) Slide, 3) Resize. + + + + Don't alter the surface position even if it is constrained on some + axis, for example partially outside the edge of an output. + + + + + Slide the surface along the x axis until it is no longer constrained. + + First try to slide towards the direction of the gravity on the x axis + until either the edge in the opposite direction of the gravity is + unconstrained or the edge in the direction of the gravity is + constrained. + + Then try to slide towards the opposite direction of the gravity on the + x axis until either the edge in the direction of the gravity is + unconstrained or the edge in the opposite direction of the gravity is + constrained. + + + + + Slide the surface along the y axis until it is no longer constrained. + + First try to slide towards the direction of the gravity on the y axis + until either the edge in the opposite direction of the gravity is + unconstrained or the edge in the direction of the gravity is + constrained. + + Then try to slide towards the opposite direction of the gravity on the + y axis until either the edge in the direction of the gravity is + unconstrained or the edge in the opposite direction of the gravity is + constrained. + + + + + Invert the anchor and gravity on the x axis if the surface is + constrained on the x axis. For example, if the left edge of the + surface is constrained, the gravity is 'left' and the anchor is + 'left', change the gravity to 'right' and the anchor to 'right'. + + If the adjusted position also ends up being constrained, the resulting + position of the flip_x adjustment will be the one before the + adjustment. + + + + + Invert the anchor and gravity on the y axis if the surface is + constrained on the y axis. For example, if the bottom edge of the + surface is constrained, the gravity is 'bottom' and the anchor is + 'bottom', change the gravity to 'top' and the anchor to 'top'. + + The adjusted position is calculated given the original anchor + rectangle and offset, but with the new flipped anchor and gravity + values. + + If the adjusted position also ends up being constrained, the resulting + position of the flip_y adjustment will be the one before the + adjustment. + + + + + Resize the surface horizontally so that it is completely + unconstrained. + + + + + Resize the surface vertically so that it is completely unconstrained. + + + + + + + Specify how the window should be positioned if the originally intended + position caused the surface to be constrained, meaning at least + partially outside positioning boundaries set by the compositor. The + adjustment is set by constructing a bitmask describing the adjustment to + be made when the surface is constrained on that axis. + + If no bit for one axis is set, the compositor will assume that the child + surface should not change its position on that axis when constrained. + + If more than one bit for one axis is set, the order of how adjustments + are applied is specified in the corresponding adjustment descriptions. + + The default adjustment is none. + + + + + + + Specify the surface position offset relative to the position of the + anchor on the anchor rectangle and the anchor on the surface. For + example if the anchor of the anchor rectangle is at (x, y), the surface + has the gravity bottom|right, and the offset is (ox, oy), the calculated + surface position will be (x + ox, y + oy). The offset position of the + surface is the one used for constraint testing. See + set_constraint_adjustment. + + An example use case is placing a popup menu on top of a user interface + element, while aligning the user interface element of the parent surface + with some user interface element placed somewhere in the popup surface. + + + + + + + + + + When set reactive, the surface is reconstrained if the conditions used + for constraining changed, e.g. the parent window moved. + + If the conditions changed and the popup was reconstrained, an + xdg_popup.configure event is sent with updated geometry, followed by an + xdg_surface.configure event. + + + + + + Set the parent window geometry the compositor should use when + positioning the popup. The compositor may use this information to + determine the future state the popup should be constrained using. If + this doesn't match the dimension of the parent the popup is eventually + positioned against, the behavior is undefined. + + The arguments are given in the surface-local coordinate space. + + + + + + + + Set the serial of an xdg_surface.configure event this positioner will be + used in response to. The compositor may use this information together + with set_parent_size to determine what future state the popup should be + constrained using. + + + + + + + + An interface that may be implemented by a wl_surface, for + implementations that provide a desktop-style user interface. + + It provides a base set of functionality required to construct user + interface elements requiring management by the compositor, such as + toplevel windows, menus, etc. The types of functionality are split into + xdg_surface roles. + + Creating an xdg_surface does not set the role for a wl_surface. In order + to map an xdg_surface, the client must create a role-specific object + using, e.g., get_toplevel, get_popup. The wl_surface for any given + xdg_surface can have at most one role, and may not be assigned any role + not based on xdg_surface. + + A role must be assigned before any other requests are made to the + xdg_surface object. + + The client must call wl_surface.commit on the corresponding wl_surface + for the xdg_surface state to take effect. + + Creating an xdg_surface from a wl_surface which has a buffer attached or + committed is a client error, and any attempts by a client to attach or + manipulate a buffer prior to the first xdg_surface.configure call must + also be treated as errors. + + After creating a role-specific object and setting it up, the client must + perform an initial commit without any buffer attached. The compositor + will reply with initial wl_surface state such as + wl_surface.preferred_buffer_scale followed by an xdg_surface.configure + event. The client must acknowledge it and is then allowed to attach a + buffer to map the surface. + + Mapping an xdg_surface-based role surface is defined as making it + possible for the surface to be shown by the compositor. Note that + a mapped surface is not guaranteed to be visible once it is mapped. + + For an xdg_surface to be mapped by the compositor, the following + conditions must be met: + (1) the client has assigned an xdg_surface-based role to the surface + (2) the client has set and committed the xdg_surface state and the + role-dependent state to the surface + (3) the client has committed a buffer to the surface + + A newly-unmapped surface is considered to have met condition (1) out + of the 3 required conditions for mapping a surface if its role surface + has not been destroyed, i.e. the client must perform the initial commit + again before attaching a buffer. + + + + + + + + + + + + + + Destroy the xdg_surface object. An xdg_surface must only be destroyed + after its role object has been destroyed, otherwise + a defunct_role_object error is raised. + + + + + + This creates an xdg_toplevel object for the given xdg_surface and gives + the associated wl_surface the xdg_toplevel role. + + See the documentation of xdg_toplevel for more details about what an + xdg_toplevel is and how it is used. + + + + + + + This creates an xdg_popup object for the given xdg_surface and gives + the associated wl_surface the xdg_popup role. + + If null is passed as a parent, a parent surface must be specified using + some other protocol, before committing the initial state. + + See the documentation of xdg_popup for more details about what an + xdg_popup is and how it is used. + + + + + + + + + The window geometry of a surface is its "visible bounds" from the + user's perspective. Client-side decorations often have invisible + portions like drop-shadows which should be ignored for the + purposes of aligning, placing and constraining windows. + + The window geometry is double buffered, and will be applied at the + time wl_surface.commit of the corresponding wl_surface is called. + + When maintaining a position, the compositor should treat the (x, y) + coordinate of the window geometry as the top left corner of the window. + A client changing the (x, y) window geometry coordinate should in + general not alter the position of the window. + + Once the window geometry of the surface is set, it is not possible to + unset it, and it will remain the same until set_window_geometry is + called again, even if a new subsurface or buffer is attached. + + If never set, the value is the full bounds of the surface, + including any subsurfaces. This updates dynamically on every + commit. This unset is meant for extremely simple clients. + + The arguments are given in the surface-local coordinate space of + the wl_surface associated with this xdg_surface, and may extend outside + of the wl_surface itself to mark parts of the subsurface tree as part of + the window geometry. + + When applied, the effective window geometry will be the set window + geometry clamped to the bounding rectangle of the combined + geometry of the surface of the xdg_surface and the associated + subsurfaces. + + The effective geometry will not be recalculated unless a new call to + set_window_geometry is done and the new pending surface state is + subsequently applied. + + The width and height of the effective window geometry must be + greater than zero. Setting an invalid size will raise an + invalid_size error. + + + + + + + + + + When a configure event is received, if a client commits the + surface in response to the configure event, then the client + must make an ack_configure request sometime before the commit + request, passing along the serial of the configure event. + + For instance, for toplevel surfaces the compositor might use this + information to move a surface to the top left only when the client has + drawn itself for the maximized or fullscreen state. + + If the client receives multiple configure events before it + can respond to one, it only has to ack the last configure event. + Acking a configure event that was never sent raises an invalid_serial + error. + + A client is not required to commit immediately after sending + an ack_configure request - it may even ack_configure several times + before its next surface commit. + + A client may send multiple ack_configure requests before committing, but + only the last request sent before a commit indicates which configure + event the client really is responding to. + + Sending an ack_configure request consumes the serial number sent with + the request, as well as serial numbers sent by all configure events + sent on this xdg_surface prior to the configure event referenced by + the committed serial. + + It is an error to issue multiple ack_configure requests referencing a + serial from the same configure event, or to issue an ack_configure + request referencing a serial from a configure event issued before the + event identified by the last ack_configure request for the same + xdg_surface. Doing so will raise an invalid_serial error. + + + + + + + The configure event marks the end of a configure sequence. A configure + sequence is a set of one or more events configuring the state of the + xdg_surface, including the final xdg_surface.configure event. + + Where applicable, xdg_surface surface roles will during a configure + sequence extend this event as a latched state sent as events before the + xdg_surface.configure event. Such events should be considered to make up + a set of atomically applied configuration states, where the + xdg_surface.configure commits the accumulated state. + + Clients should arrange their surface for the new states, and then send + an ack_configure request with the serial sent in this configure event at + some point before committing the new surface. + + If the client receives multiple configure events before it can respond + to one, it is free to discard all but the last event it received. + + + + + + + + + This interface defines an xdg_surface role which allows a surface to, + among other things, set window-like properties such as maximize, + fullscreen, and minimize, set application-specific metadata like title and + id, and well as trigger user interactive operations such as interactive + resize and move. + + Unmapping an xdg_toplevel means that the surface cannot be shown + by the compositor until it is explicitly mapped again. + All active operations (e.g., move, resize) are canceled and all + attributes (e.g. title, state, stacking, ...) are discarded for + an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to + the state it had right after xdg_surface.get_toplevel. The client + can re-map the toplevel by perfoming a commit without any buffer + attached, waiting for a configure event and handling it as usual (see + xdg_surface description). + + Attaching a null buffer to a toplevel unmaps the surface. + + + + + This request destroys the role surface and unmaps the surface; + see "Unmapping" behavior in interface section for details. + + + + + + + + + + + + Set the "parent" of this surface. This surface should be stacked + above the parent surface and all other ancestor surfaces. + + Parent surfaces should be set on dialogs, toolboxes, or other + "auxiliary" surfaces, so that the parent is raised when the dialog + is raised. + + Setting a null parent for a child surface unsets its parent. Setting + a null parent for a surface which currently has no parent is a no-op. + + Only mapped surfaces can have child surfaces. Setting a parent which + is not mapped is equivalent to setting a null parent. If a surface + becomes unmapped, its children's parent is set to the parent of + the now-unmapped surface. If the now-unmapped surface has no parent, + its children's parent is unset. If the now-unmapped surface becomes + mapped again, its parent-child relationship is not restored. + + The parent toplevel must not be one of the child toplevel's + descendants, and the parent must be different from the child toplevel, + otherwise the invalid_parent protocol error is raised. + + + + + + + Set a short title for the surface. + + This string may be used to identify the surface in a task bar, + window list, or other user interface elements provided by the + compositor. + + The string must be encoded in UTF-8. + + + + + + + Set an application identifier for the surface. + + The app ID identifies the general class of applications to which + the surface belongs. The compositor can use this to group multiple + surfaces together, or to determine how to launch a new application. + + For D-Bus activatable applications, the app ID is used as the D-Bus + service name. + + The compositor shell will try to group application surfaces together + by their app ID. As a best practice, it is suggested to select app + ID's that match the basename of the application's .desktop file. + For example, "org.freedesktop.FooViewer" where the .desktop file is + "org.freedesktop.FooViewer.desktop". + + Like other properties, a set_app_id request can be sent after the + xdg_toplevel has been mapped to update the property. + + See the desktop-entry specification [0] for more details on + application identifiers and how they relate to well-known D-Bus + names and .desktop files. + + [0] https://standards.freedesktop.org/desktop-entry-spec/ + + + + + + + Clients implementing client-side decorations might want to show + a context menu when right-clicking on the decorations, giving the + user a menu that they can use to maximize or minimize the window. + + This request asks the compositor to pop up such a window menu at + the given position, relative to the local surface coordinates of + the parent surface. There are no guarantees as to what menu items + the window menu contains, or even if a window menu will be drawn + at all. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. + + + + + + + + + + Start an interactive, user-driven move of the surface. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. The passed + serial is used to determine the type of interactive move (touch, + pointer, etc). + + The server may ignore move requests depending on the state of + the surface (e.g. fullscreen or maximized), or if the passed serial + is no longer valid. + + If triggered, the surface will lose the focus of the device + (wl_pointer, wl_touch, etc) used for the move. It is up to the + compositor to visually indicate that the move is taking place, such as + updating a pointer cursor, during the move. There is no guarantee + that the device focus will return when the move is completed. + + + + + + + + These values are used to indicate which edge of a surface + is being dragged in a resize operation. + + + + + + + + + + + + + + + Start a user-driven, interactive resize of the surface. + + This request must be used in response to some sort of user action + like a button press, key press, or touch down event. The passed + serial is used to determine the type of interactive resize (touch, + pointer, etc). + + The server may ignore resize requests depending on the state of + the surface (e.g. fullscreen or maximized). + + If triggered, the client will receive configure events with the + "resize" state enum value and the expected sizes. See the "resize" + enum value for more details about what is required. The client + must also acknowledge configure events using "ack_configure". After + the resize is completed, the client will receive another "configure" + event without the resize state. + + If triggered, the surface also will lose the focus of the device + (wl_pointer, wl_touch, etc) used for the resize. It is up to the + compositor to visually indicate that the resize is taking place, + such as updating a pointer cursor, during the resize. There is no + guarantee that the device focus will return when the resize is + completed. + + The edges parameter specifies how the surface should be resized, and + is one of the values of the resize_edge enum. Values not matching + a variant of the enum will cause the invalid_resize_edge protocol error. + The compositor may use this information to update the surface position + for example when dragging the top left corner. The compositor may also + use this information to adapt its behavior, e.g. choose an appropriate + cursor image. + + + + + + + + + The different state values used on the surface. This is designed for + state values like maximized, fullscreen. It is paired with the + configure event to ensure that both the client and the compositor + setting the state can be synchronized. + + States set in this way are double-buffered. They will get applied on + the next commit. + + + + The surface is maximized. The window geometry specified in the configure + event must be obeyed by the client, or the xdg_wm_base.invalid_surface_state + error is raised. + + The client should draw without shadow or other + decoration outside of the window geometry. + + + + + The surface is fullscreen. The window geometry specified in the + configure event is a maximum; the client cannot resize beyond it. For + a surface to cover the whole fullscreened area, the geometry + dimensions must be obeyed by the client. For more details, see + xdg_toplevel.set_fullscreen. + + + + + The surface is being resized. The window geometry specified in the + configure event is a maximum; the client cannot resize beyond it. + Clients that have aspect ratio or cell sizing configuration can use + a smaller size, however. + + + + + Client window decorations should be painted as if the window is + active. Do not assume this means that the window actually has + keyboard or pointer focus. + + + + + The window is currently in a tiled layout and the left edge is + considered to be adjacent to another part of the tiling grid. + + + + + The window is currently in a tiled layout and the right edge is + considered to be adjacent to another part of the tiling grid. + + + + + The window is currently in a tiled layout and the top edge is + considered to be adjacent to another part of the tiling grid. + + + + + The window is currently in a tiled layout and the bottom edge is + considered to be adjacent to another part of the tiling grid. + + + + + The surface is currently not ordinarily being repainted; for + example because its content is occluded by another window, or its + outputs are switched off due to screen locking. + + + + + + + Set a maximum size for the window. + + The client can specify a maximum size so that the compositor does + not try to configure the window beyond this size. + + The width and height arguments are in window geometry coordinates. + See xdg_surface.set_window_geometry. + + Values set in this way are double-buffered. They will get applied + on the next commit. + + The compositor can use this information to allow or disallow + different states like maximize or fullscreen and draw accurate + animations. + + Similarly, a tiling window manager may use this information to + place and resize client windows in a more effective way. + + The client should not rely on the compositor to obey the maximum + size. The compositor may decide to ignore the values set by the + client and request a larger size. + + If never set, or a value of zero in the request, means that the + client has no expected maximum size in the given dimension. + As a result, a client wishing to reset the maximum size + to an unspecified state can use zero for width and height in the + request. + + Requesting a maximum size to be smaller than the minimum size of + a surface is illegal and will result in an invalid_size error. + + The width and height must be greater than or equal to zero. Using + strictly negative values for width or height will result in a + invalid_size error. + + + + + + + + Set a minimum size for the window. + + The client can specify a minimum size so that the compositor does + not try to configure the window below this size. + + The width and height arguments are in window geometry coordinates. + See xdg_surface.set_window_geometry. + + Values set in this way are double-buffered. They will get applied + on the next commit. + + The compositor can use this information to allow or disallow + different states like maximize or fullscreen and draw accurate + animations. + + Similarly, a tiling window manager may use this information to + place and resize client windows in a more effective way. + + The client should not rely on the compositor to obey the minimum + size. The compositor may decide to ignore the values set by the + client and request a smaller size. + + If never set, or a value of zero in the request, means that the + client has no expected minimum size in the given dimension. + As a result, a client wishing to reset the minimum size + to an unspecified state can use zero for width and height in the + request. + + Requesting a minimum size to be larger than the maximum size of + a surface is illegal and will result in an invalid_size error. + + The width and height must be greater than or equal to zero. Using + strictly negative values for width and height will result in a + invalid_size error. + + + + + + + + Maximize the surface. + + After requesting that the surface should be maximized, the compositor + will respond by emitting a configure event. Whether this configure + actually sets the window maximized is subject to compositor policies. + The client must then update its content, drawing in the configured + state. The client must also acknowledge the configure when committing + the new content (see ack_configure). + + It is up to the compositor to decide how and where to maximize the + surface, for example which output and what region of the screen should + be used. + + If the surface was already maximized, the compositor will still emit + a configure event with the "maximized" state. + + If the surface is in a fullscreen state, this request has no direct + effect. It may alter the state the surface is returned to when + unmaximized unless overridden by the compositor. + + + + + + Unmaximize the surface. + + After requesting that the surface should be unmaximized, the compositor + will respond by emitting a configure event. Whether this actually + un-maximizes the window is subject to compositor policies. + If available and applicable, the compositor will include the window + geometry dimensions the window had prior to being maximized in the + configure event. The client must then update its content, drawing it in + the configured state. The client must also acknowledge the configure + when committing the new content (see ack_configure). + + It is up to the compositor to position the surface after it was + unmaximized; usually the position the surface had before maximizing, if + applicable. + + If the surface was already not maximized, the compositor will still + emit a configure event without the "maximized" state. + + If the surface is in a fullscreen state, this request has no direct + effect. It may alter the state the surface is returned to when + unmaximized unless overridden by the compositor. + + + + + + Make the surface fullscreen. + + After requesting that the surface should be fullscreened, the + compositor will respond by emitting a configure event. Whether the + client is actually put into a fullscreen state is subject to compositor + policies. The client must also acknowledge the configure when + committing the new content (see ack_configure). + + The output passed by the request indicates the client's preference as + to which display it should be set fullscreen on. If this value is NULL, + it's up to the compositor to choose which display will be used to map + this surface. + + If the surface doesn't cover the whole output, the compositor will + position the surface in the center of the output and compensate with + with border fill covering the rest of the output. The content of the + border fill is undefined, but should be assumed to be in some way that + attempts to blend into the surrounding area (e.g. solid black). + + If the fullscreened surface is not opaque, the compositor must make + sure that other screen content not part of the same surface tree (made + up of subsurfaces, popups or similarly coupled surfaces) are not + visible below the fullscreened surface. + + + + + + + Make the surface no longer fullscreen. + + After requesting that the surface should be unfullscreened, the + compositor will respond by emitting a configure event. + Whether this actually removes the fullscreen state of the client is + subject to compositor policies. + + Making a surface unfullscreen sets states for the surface based on the following: + * the state(s) it may have had before becoming fullscreen + * any state(s) decided by the compositor + * any state(s) requested by the client while the surface was fullscreen + + The compositor may include the previous window geometry dimensions in + the configure event, if applicable. + + The client must also acknowledge the configure when committing the new + content (see ack_configure). + + + + + + Request that the compositor minimize your surface. There is no + way to know if the surface is currently minimized, nor is there + any way to unset minimization on this surface. + + If you are looking to throttle redrawing when minimized, please + instead use the wl_surface.frame event for this, as this will + also work with live previews on windows in Alt-Tab, Expose or + similar compositor features. + + + + + + This configure event asks the client to resize its toplevel surface or + to change its state. The configured state should not be applied + immediately. See xdg_surface.configure for details. + + The width and height arguments specify a hint to the window + about how its surface should be resized in window geometry + coordinates. See set_window_geometry. + + If the width or height arguments are zero, it means the client + should decide its own window dimension. This may happen when the + compositor needs to configure the state of the surface but doesn't + have any information about any previous or expected dimension. + + The states listed in the event specify how the width/height + arguments should be interpreted, and possibly how it should be + drawn. + + Clients must send an ack_configure in response to this event. See + xdg_surface.configure and xdg_surface.ack_configure for details. + + + + + + + + + The close event is sent by the compositor when the user + wants the surface to be closed. This should be equivalent to + the user clicking the close button in client-side decorations, + if your application has any. + + This is only a request that the user intends to close the + window. The client may choose to ignore this request, or show + a dialog to ask the user to save their data, etc. + + + + + + + + The configure_bounds event may be sent prior to a xdg_toplevel.configure + event to communicate the bounds a window geometry size is recommended + to constrain to. + + The passed width and height are in surface coordinate space. If width + and height are 0, it means bounds is unknown and equivalent to as if no + configure_bounds event was ever sent for this surface. + + The bounds can for example correspond to the size of a monitor excluding + any panels or other shell components, so that a surface isn't created in + a way that it cannot fit. + + The bounds may change at any point, and in such a case, a new + xdg_toplevel.configure_bounds will be sent, followed by + xdg_toplevel.configure and xdg_surface.configure. + + + + + + + + + + + + + + + + + This event advertises the capabilities supported by the compositor. If + a capability isn't supported, clients should hide or disable the UI + elements that expose this functionality. For instance, if the + compositor doesn't advertise support for minimized toplevels, a button + triggering the set_minimized request should not be displayed. + + The compositor will ignore requests it doesn't support. For instance, + a compositor which doesn't advertise support for minimized will ignore + set_minimized requests. + + Compositors must send this event once before the first + xdg_surface.configure event. When the capabilities change, compositors + must send this event again and then send an xdg_surface.configure + event. + + The configured state should not be applied immediately. See + xdg_surface.configure for details. + + The capabilities are sent as an array of 32-bit unsigned integers in + native endianness. + + + + + + + + A popup surface is a short-lived, temporary surface. It can be used to + implement for example menus, popovers, tooltips and other similar user + interface concepts. + + A popup can be made to take an explicit grab. See xdg_popup.grab for + details. + + When the popup is dismissed, a popup_done event will be sent out, and at + the same time the surface will be unmapped. See the xdg_popup.popup_done + event for details. + + Explicitly destroying the xdg_popup object will also dismiss the popup and + unmap the surface. Clients that want to dismiss the popup when another + surface of their own is clicked should dismiss the popup using the destroy + request. + + A newly created xdg_popup will be stacked on top of all previously created + xdg_popup surfaces associated with the same xdg_toplevel. + + The parent of an xdg_popup must be mapped (see the xdg_surface + description) before the xdg_popup itself. + + The client must call wl_surface.commit on the corresponding wl_surface + for the xdg_popup state to take effect. + + + + + + + + + This destroys the popup. Explicitly destroying the xdg_popup + object will also dismiss the popup, and unmap the surface. + + If this xdg_popup is not the "topmost" popup, the + xdg_wm_base.not_the_topmost_popup protocol error will be sent. + + + + + + This request makes the created popup take an explicit grab. An explicit + grab will be dismissed when the user dismisses the popup, or when the + client destroys the xdg_popup. This can be done by the user clicking + outside the surface, using the keyboard, or even locking the screen + through closing the lid or a timeout. + + If the compositor denies the grab, the popup will be immediately + dismissed. + + This request must be used in response to some sort of user action like a + button press, key press, or touch down event. The serial number of the + event should be passed as 'serial'. + + The parent of a grabbing popup must either be an xdg_toplevel surface or + another xdg_popup with an explicit grab. If the parent is another + xdg_popup it means that the popups are nested, with this popup now being + the topmost popup. + + Nested popups must be destroyed in the reverse order they were created + in, e.g. the only popup you are allowed to destroy at all times is the + topmost one. + + When compositors choose to dismiss a popup, they may dismiss every + nested grabbing popup as well. When a compositor dismisses popups, it + will follow the same dismissing order as required from the client. + + If the topmost grabbing popup is destroyed, the grab will be returned to + the parent of the popup, if that parent previously had an explicit grab. + + If the parent is a grabbing popup which has already been dismissed, this + popup will be immediately dismissed. If the parent is a popup that did + not take an explicit grab, an error will be raised. + + During a popup grab, the client owning the grab will receive pointer + and touch events for all their surfaces as normal (similar to an + "owner-events" grab in X11 parlance), while the top most grabbing popup + will always have keyboard focus. + + + + + + + + This event asks the popup surface to configure itself given the + configuration. The configured state should not be applied immediately. + See xdg_surface.configure for details. + + The x and y arguments represent the position the popup was placed at + given the xdg_positioner rule, relative to the upper left corner of the + window geometry of the parent surface. + + For version 2 or older, the configure event for an xdg_popup is only + ever sent once for the initial configuration. Starting with version 3, + it may be sent again if the popup is setup with an xdg_positioner with + set_reactive requested, or in response to xdg_popup.reposition requests. + + + + + + + + + + The popup_done event is sent out when a popup is dismissed by the + compositor. The client should destroy the xdg_popup object at this + point. + + + + + + + + Reposition an already-mapped popup. The popup will be placed given the + details in the passed xdg_positioner object, and a + xdg_popup.repositioned followed by xdg_popup.configure and + xdg_surface.configure will be emitted in response. Any parameters set + by the previous positioner will be discarded. + + The passed token will be sent in the corresponding + xdg_popup.repositioned event. The new popup position will not take + effect until the corresponding configure event is acknowledged by the + client. See xdg_popup.repositioned for details. The token itself is + opaque, and has no other special meaning. + + If multiple reposition requests are sent, the compositor may skip all + but the last one. + + If the popup is repositioned in response to a configure event for its + parent, the client should send an xdg_positioner.set_parent_configure + and possibly an xdg_positioner.set_parent_size request to allow the + compositor to properly constrain the popup. + + If the popup is repositioned together with a parent that is being + resized, but not in response to a configure event, the client should + send an xdg_positioner.set_parent_size request. + + + + + + + + The repositioned event is sent as part of a popup configuration + sequence, together with xdg_popup.configure and lastly + xdg_surface.configure to notify the completion of a reposition request. + + The repositioned event is to notify about the completion of a + xdg_popup.reposition request. The token argument is the token passed + in the xdg_popup.reposition request. + + Immediately after this event is emitted, xdg_popup.configure and + xdg_surface.configure will be sent with the updated size and position, + as well as a new configure serial. + + The client should optionally update the content of the popup, but must + acknowledge the new popup configuration for the new position to take + effect. See xdg_surface.ack_configure for details. + + + + + + diff --git a/docs/compat.dox b/docs/compat.dox index e9506c57..49b52bf4 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -100,54 +100,45 @@ has sole responsibility for interacting well with every compositor in use on Unix-like systems. Most of the features are provided by the core protocol, while cursor support is provided by the libwayland-cursor helper library, EGL integration by libwayland-egl, and keyboard handling by -[libxkbcommon](https://xkbcommon.org/). In addition, GLFW uses some protocols -from wayland-protocols to provide additional features if the compositor -supports them. +[libxkbcommon](https://xkbcommon.org/). In addition, GLFW uses some additional +Wayland protocols to implement certain features if the compositor supports them. GLFW uses xkbcommon 0.5.0 to provide key and text input support. Earlier versions are not supported. -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 is mandatory for GLFW to display a window. +GLFW uses the [xdg-shell protocol](https://wayland.app/protocols/xdg-shell) +to provide better window management. This protocol 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) -alongside the [pointer constraints -protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml) -to implement disabled cursor. These two protocols are part of -wayland-protocols 1.1, and mandatory at build time. If the running compositor -does not support both of these protocols, disabling the cursor will have no -effect. +GLFW uses the +[relative pointer protocol](https://wayland.app/protocols/relative-pointer-unstable-v1) +alongside the +[pointer constraints protocol](https://wayland.app/protocols/pointer-constraints-unstable-v1) +to implement disabled cursor. If the running compositor does not support both +of these protocols, disabling the cursor will have no effect. -GLFW uses the [idle inhibit -protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml) -to prohibit the screensaver from starting. This protocol is part of -wayland-protocols 1.6, and mandatory at build time. If the running compositor -does not support this protocol, the screensaver may start even for full screen -windows. +GLFW uses the +[idle inhibit protocol](https://wayland.app/protocols/idle-inhibit-unstable-v1) +to prohibit the screensaver from starting. If the running compositor does not +support this protocol, the screensaver may start even for full screen windows. -GLFW uses the [libdecor library](https://gitlab.freedesktop.org/libdecor/libdecor) -for window decorations, where available. This in turn provides good quality -client-side decorations (drawn by the application) on desktop systems that do -not support server-side decorations (drawn by the window manager). On systems -that do not provide either libdecor or xdg-decoration, very basic window -decorations are provided. These do not include the window title or any caption -buttons. +GLFW uses the +[libdecor library](https://gitlab.freedesktop.org/libdecor/libdecor) for window +decorations, where available. This in turn provides good quality client-side +decorations (drawn by the application) on desktop systems that do not support +server-side decorations (drawn by the window manager). On systems that do not +provide either libdecor or xdg-decoration, very basic window decorations are +provided. These do not include the window title or any caption buttons. -GLFW uses the [xdg-decoration -protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml) +GLFW uses the +[xdg-decoration protocol](https://wayland.app/protocols/xdg-decoration-unstable-v1) to request decorations to be drawn around its windows. This protocol is part of wayland-protocols 1.15, and mandatory at build time. If the running compositor does not support this protocol, a very simple frame will be drawn by -GLFW itself, using the [viewporter -protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/viewporter/viewporter.xml) -alongside -[subsurfaces](https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml#n2598). -This protocol is part of wayland-protocols 1.4, and mandatory at build time. -If the running compositor does not support this protocol either, no decorations -will be drawn around windows. +GLFW itself, using the +[viewporter protocol](https://wayland.app/protocols/viewporter) +alongside subsurfaces. If the running compositor does not support these +protocols either, no decorations will be drawn around windows. @section compat_glx GLX extensions diff --git a/docs/compile.dox b/docs/compile.dox index 3490eb15..4968af40 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -83,29 +83,28 @@ development packages installed. They are not needed to build or run programs th GLFW. You will also need to set the @ref GLFW_BUILD_WAYLAND CMake option in the next step when generating build files. -On Debian and derivatives like Ubuntu and Linux Mint you will need the `libwayland-dev`, -`libxkbcommon-dev` and `wayland-protocols` packages and the `xorg-dev` meta-package. -These will pull in all other dependencies. +On Debian and derivatives like Ubuntu and Linux Mint you will need the `libwayland-dev` +and `libxkbcommon-dev` packages and the `xorg-dev` meta-package. These will pull in all +other dependencies. @code{.sh} -sudo apt install libwayland-dev libxkbcommon-dev wayland-protocols xorg-dev +sudo apt install libwayland-dev libxkbcommon-dev xorg-dev @endcode On Fedora and derivatives like Red Hat you will need the `wayland-devel`, -`libxkbcommon-devel`, `wayland-protocols-devel`, `libXcursor-devel`, `libXi-devel`, -`libXinerama-devel` and `libXrandr-devel` packages. These will pull in all other -dependencies. +`libxkbcommon-devel`, `libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and +`libXrandr-devel` packages. These will pull in all other dependencies. @code{.sh} -sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel +sudo dnf install wayland-devel libxkbcommon-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel @endcode -On FreeBSD you will need the `wayland`, `libxkbcommon` and `wayland-protocols` packages. -The X11 headers are installed along the end-user X11 packages, so if you have an X server -running you should have the headers as well. If not, install the `xorgproto` package. +On FreeBSD you will need the `wayland` and `libxkbcommon` packages. The X11 headers are +installed along the end-user X11 packages, so if you have an X server running you should +have the headers as well. If not, install the `xorgproto` package. @code{.sh} -pkg install wayland libxkbcommon wayland-protocols xorgproto +pkg install wayland libxkbcommon xorgproto @endcode Once you have the required dependencies, move on to @ref compile_generate. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7b84ecf2..d1ccf484 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -72,47 +72,36 @@ if (GLFW_BUILD_WAYLAND) endif() find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner) + if (NOT WAYLAND_SCANNER_EXECUTABLE) + message(FATAL_ERROR "Failed to find wayland-scanner") + endif() - include(FindPkgConfig) - pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.15) - pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir) - pkg_get_variable(WAYLAND_CLIENT_PKGDATADIR wayland-client pkgdatadir) + macro(generate_wayland_protocol protocol_file) + set(protocol_path "${GLFW_SOURCE_DIR}/deps/wayland/${protocol_file}") - macro(wayland_generate protocol_file output_file) - add_custom_command(OUTPUT "${output_file}.h" - COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h" - DEPENDS "${protocol_file}" + string(REGEX REPLACE "\\.xml$" "-client-protocol.h" header_file ${protocol_file}) + string(REGEX REPLACE "\\.xml$" "-client-protocol-code.h" code_file ${protocol_file}) + + add_custom_command(OUTPUT ${header_file} + COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_path}" ${header_file} + DEPENDS "${protocol_path}" VERBATIM) - add_custom_command(OUTPUT "${output_file}-code.h" - COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}-code.h" - DEPENDS "${protocol_file}" + add_custom_command(OUTPUT ${code_file} + COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_path}" ${code_file} + DEPENDS "${protocol_path}" VERBATIM) - target_sources(glfw PRIVATE "${output_file}.h" "${output_file}-code.h") + target_sources(glfw PRIVATE ${header_file} ${code_file}) endmacro() - wayland_generate( - "${WAYLAND_CLIENT_PKGDATADIR}/wayland.xml" - "${GLFW_BINARY_DIR}/src/wayland-client-protocol") - wayland_generate( - "${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml" - "${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol") - wayland_generate( - "${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml" - "${GLFW_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol") - wayland_generate( - "${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml" - "${GLFW_BINARY_DIR}/src/wayland-viewporter-client-protocol") - wayland_generate( - "${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml" - "${GLFW_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol") - wayland_generate( - "${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml" - "${GLFW_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol") - wayland_generate( - "${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" - "${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol") + generate_wayland_protocol("wayland.xml") + generate_wayland_protocol("viewporter.xml") + generate_wayland_protocol("xdg-shell.xml") + generate_wayland_protocol("idle-inhibit-unstable-v1.xml") + generate_wayland_protocol("pointer-constraints-unstable-v1.xml") + generate_wayland_protocol("relative-pointer-unstable-v1.xml") + generate_wayland_protocol("xdg-decoration-unstable-v1.xml") endif() if (WIN32 AND GLFW_BUILD_SHARED_LIBRARY) @@ -167,6 +156,8 @@ if (GLFW_BUILD_COCOA) endif() if (GLFW_BUILD_WAYLAND) + include(FindPkgConfig) + pkg_check_modules(Wayland REQUIRED wayland-client>=0.2.7 wayland-cursor>=0.2.7 diff --git a/src/wl_init.c b/src/wl_init.c index fd6b7e9c..5790cfc4 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -43,12 +43,12 @@ #include #include "wayland-client-protocol.h" -#include "wayland-xdg-shell-client-protocol.h" -#include "wayland-xdg-decoration-client-protocol.h" -#include "wayland-viewporter-client-protocol.h" -#include "wayland-relative-pointer-unstable-v1-client-protocol.h" -#include "wayland-pointer-constraints-unstable-v1-client-protocol.h" -#include "wayland-idle-inhibit-unstable-v1-client-protocol.h" +#include "xdg-shell-client-protocol.h" +#include "xdg-decoration-unstable-v1-client-protocol.h" +#include "viewporter-client-protocol.h" +#include "relative-pointer-unstable-v1-client-protocol.h" +#include "pointer-constraints-unstable-v1-client-protocol.h" +#include "idle-inhibit-unstable-v1-client-protocol.h" // NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of // wl_interface pointers 'types', making it impossible to combine several unmodified @@ -60,27 +60,27 @@ #undef types #define types _glfw_xdg_shell_types -#include "wayland-xdg-shell-client-protocol-code.h" +#include "xdg-shell-client-protocol-code.h" #undef types #define types _glfw_xdg_decoration_types -#include "wayland-xdg-decoration-client-protocol-code.h" +#include "xdg-decoration-unstable-v1-client-protocol-code.h" #undef types #define types _glfw_viewporter_types -#include "wayland-viewporter-client-protocol-code.h" +#include "viewporter-client-protocol-code.h" #undef types #define types _glfw_relative_pointer_types -#include "wayland-relative-pointer-unstable-v1-client-protocol-code.h" +#include "relative-pointer-unstable-v1-client-protocol-code.h" #undef types #define types _glfw_pointer_constraints_types -#include "wayland-pointer-constraints-unstable-v1-client-protocol-code.h" +#include "pointer-constraints-unstable-v1-client-protocol-code.h" #undef types #define types _glfw_idle_inhibit_types -#include "wayland-idle-inhibit-unstable-v1-client-protocol-code.h" +#include "idle-inhibit-unstable-v1-client-protocol-code.h" #undef types static void wmBaseHandlePing(void* userData, @@ -805,13 +805,11 @@ int _glfwInitWayland(void) } } -#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION if (wl_seat_get_version(_glfw.wl.seat) >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) { _glfw.wl.keyRepeatTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); } -#endif if (!_glfw.wl.wmBase) { diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 0b1a3d8d..b56f3dfb 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -130,8 +130,6 @@ static void outputHandleScale(void* userData, } } -#ifdef WL_OUTPUT_NAME_SINCE_VERSION - void outputHandleName(void* userData, struct wl_output* wl_output, const char* name) { struct _GLFWmonitor* monitor = userData; @@ -145,18 +143,14 @@ void outputHandleDescription(void* userData, { } -#endif // WL_OUTPUT_NAME_SINCE_VERSION - static const struct wl_output_listener outputListener = { outputHandleGeometry, outputHandleMode, outputHandleDone, outputHandleScale, -#ifdef WL_OUTPUT_NAME_SINCE_VERSION outputHandleName, outputHandleDescription, -#endif }; @@ -173,11 +167,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version) return; } -#ifdef WL_OUTPUT_NAME_SINCE_VERSION version = _glfw_min(version, WL_OUTPUT_NAME_SINCE_VERSION); -#else - version = 2; -#endif struct wl_output* output = wl_registry_bind(_glfw.wl.registry, name, diff --git a/src/wl_window.c b/src/wl_window.c index 7c509896..86b5b0fd 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -44,12 +44,12 @@ #include #include "wayland-client-protocol.h" -#include "wayland-xdg-shell-client-protocol.h" -#include "wayland-xdg-decoration-client-protocol.h" -#include "wayland-viewporter-client-protocol.h" -#include "wayland-relative-pointer-unstable-v1-client-protocol.h" -#include "wayland-pointer-constraints-unstable-v1-client-protocol.h" -#include "wayland-idle-inhibit-unstable-v1-client-protocol.h" +#include "xdg-shell-client-protocol.h" +#include "xdg-decoration-unstable-v1-client-protocol.h" +#include "viewporter-client-protocol.h" +#include "relative-pointer-unstable-v1-client-protocol.h" +#include "pointer-constraints-unstable-v1-client-protocol.h" +#include "idle-inhibit-unstable-v1-client-protocol.h" #define GLFW_BORDER_SIZE 4 #define GLFW_CAPTION_HEIGHT 24 @@ -1756,7 +1756,6 @@ static void keyboardHandleModifiers(void* userData, } } -#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION static void keyboardHandleRepeatInfo(void* userData, struct wl_keyboard* keyboard, int32_t rate, @@ -1768,7 +1767,6 @@ static void keyboardHandleRepeatInfo(void* userData, _glfw.wl.keyRepeatRate = rate; _glfw.wl.keyRepeatDelay = delay; } -#endif static const struct wl_keyboard_listener keyboardListener = { @@ -1777,9 +1775,7 @@ static const struct wl_keyboard_listener keyboardListener = keyboardHandleLeave, keyboardHandleKey, keyboardHandleModifiers, -#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION keyboardHandleRepeatInfo, -#endif }; static void seatHandleCapabilities(void* userData, From 29885c69422d837d210405b5ea1701286586f383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 Jan 2020 03:25:54 +0100 Subject: [PATCH 011/137] Win32: Improve clipboard contention issue This is primarily a workaround for a GLFW application reading and/or writing to the clipboard in rapid succession and catching up with the Windows Clipboard History, which also has to contend for the lock. --- README.md | 1 + include/GLFW/glfw3.h | 10 ++++++++++ src/win32_window.c | 37 +++++++++++++++++++++++++++---------- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cebe62bc..fe5d060a 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408) - [Win32] Bugfix: Fix pkg-config for dynamic library on Windows (#2386, #2420) - [Win32] Bugfix: XInput could reportedly provide invalid DPad bit masks (#2291) + - [Win32] Bugfix: Rapid clipboard calls could fail due to Clipboard History - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index c947f17d..e2d16b61 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -5814,6 +5814,11 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * + * @remark @win32 The clipboard on Windows has a single global lock for reading and + * writing. GLFW tries to acquire it a few times, which is almost always enough. If it + * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns. + * It is safe to try this multiple times. + * * @pointer_lifetime The specified string is copied before this function * returns. * @@ -5842,6 +5847,11 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_FORMAT_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * + * @remark @win32 The clipboard on Windows has a single global lock for reading and + * writing. GLFW tries to acquire it a few times, which is almost always enough. If it + * cannot acquire the lock then this function emits @ref GLFW_PLATFORM_ERROR and returns. + * It is safe to try this multiple times. + * * @pointer_lifetime The returned string is allocated and freed by GLFW. You * should not free it yourself. It is valid until the next call to @ref * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library diff --git a/src/win32_window.c b/src/win32_window.c index a4a18171..28f8d585 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2293,7 +2293,7 @@ void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor) void _glfwSetClipboardStringWin32(const char* string) { - int characterCount; + int characterCount, tries = 0; HANDLE object; WCHAR* buffer; @@ -2321,12 +2321,20 @@ void _glfwSetClipboardStringWin32(const char* string) MultiByteToWideChar(CP_UTF8, 0, string, -1, buffer, characterCount); GlobalUnlock(object); - if (!OpenClipboard(_glfw.win32.helperWindowHandle)) + // NOTE: Retry clipboard opening a few times as some other application may have it + // open and also the Windows Clipboard History reads it after each update + while (!OpenClipboard(_glfw.win32.helperWindowHandle)) { - _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, - "Win32: Failed to open clipboard"); - GlobalFree(object); - return; + Sleep(1); + tries++; + + if (tries == 3) + { + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, + "Win32: Failed to open clipboard"); + GlobalFree(object); + return; + } } EmptyClipboard(); @@ -2338,12 +2346,21 @@ const char* _glfwGetClipboardStringWin32(void) { HANDLE object; WCHAR* buffer; + int tries = 0; - if (!OpenClipboard(_glfw.win32.helperWindowHandle)) + // NOTE: Retry clipboard opening a few times as some other application may have it + // open and also the Windows Clipboard History reads it after each update + while (!OpenClipboard(_glfw.win32.helperWindowHandle)) { - _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, - "Win32: Failed to open clipboard"); - return NULL; + Sleep(1); + tries++; + + if (tries == 3) + { + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, + "Win32: Failed to open clipboard"); + return NULL; + } } object = GetClipboardData(CF_UNICODETEXT); From 507621977f81dcbf926e8452bcbc1b147570016a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 11 Jan 2024 18:03:18 +0100 Subject: [PATCH 012/137] Win32: Remove unofficial support for VS 2008 Related to #2465 --- deps/vs2008/stdint.h | 247 ------------------------------------------- src/CMakeLists.txt | 14 --- 2 files changed, 261 deletions(-) delete mode 100644 deps/vs2008/stdint.h diff --git a/deps/vs2008/stdint.h b/deps/vs2008/stdint.h deleted file mode 100644 index d02608a5..00000000 --- a/deps/vs2008/stdint.h +++ /dev/null @@ -1,247 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -# include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d1ccf484..42f4e014 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -292,20 +292,6 @@ if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) endif() -# Workaround for VS 2008 not shipping with stdint.h -if (MSVC90) - target_include_directories(glfw PUBLIC "${GLFW_SOURCE_DIR}/deps/vs2008") -endif() - -# Check for the DirectX 9 SDK as it is not included with VS 2008 -if (MSVC90) - include(CheckIncludeFile) - check_include_file(dinput.h DINPUT_H_FOUND) - if (NOT DINPUT_H_FOUND) - message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK") - endif() -endif() - # Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE) From 200639712b15ca7b845d3890e0e6e89ba821ad53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 12 Jan 2024 13:02:50 +0100 Subject: [PATCH 013/137] Add initial .editorconfig file --- .editorconfig | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..d5e0290f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,67 @@ +# EditorConfig for GLFW and its internal dependencies +# +# All files created by GLFW should indent with four spaces unless their format requires +# otherwise. A few files still use other indent styles for historical reasons. +# +# Dependencies have (what seemed to be) their existing styles described. Those with +# existing trailing whitespace have it preserved to avoid cluttering future commits. + +root = true + +[*] +charset = utf-8 +end_of_line = lf + +[include/GLFW/*.h] +indent_style = space +indent_size = 4 + +[{src,examples,tests}/*.{c,m,h,rc,in}] +indent_style = space +indent_size = 4 + +[CMakeLists.txt] +indent_style = space +indent_size = 4 + +[CMake/**.{cmake,in}] +indent_style = space +indent_size = 4 + +[*.{dox,md}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = false + +[DoxygenLayout.xml] +indent_style = space +indent_size = 2 + +[docs/*.{scss,html}] +indent_style = tab +indent_size = unset + +[deps/mingw/*.h] +indent_style = space +indent_size = 4 +tab_width = 8 +trim_trailing_whitespace = false + +[deps/getopt.{c,h}] +indent_style = space +indent_size = 2 + +[deps/linmath.h] +indent_style = tab +tab_width = 4 +indent_size = 4 +trim_trailing_whitespace = false + +[deps/nuklear*.h] +indent_style = space +indent_size = 4 + +[deps/tinycthread.{c,h}] +indent_style = space +indent_size = 2 + From d2b88cf7ab6eb8a0501985d10969641a4ba74c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 12 Jan 2024 17:42:37 +0100 Subject: [PATCH 014/137] Update documentation for native access errors The GLFW_PLATFORM_UNAVAILABLE error was not listed for those native access function that can emit it. The order of errors for many functions in glfw3native.h did not match the order used in glfw3.h. The documentation for GLFW_PLATFORM_UNAVAILABLE was a little bit terse. --- include/GLFW/glfw3.h | 10 ++--- include/GLFW/glfw3native.h | 80 ++++++++++++++++++++++---------------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e2d16b61..5e6fad42 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -827,11 +827,11 @@ extern "C" { #define GLFW_FEATURE_UNIMPLEMENTED 0x0001000D /*! @brief Platform unavailable or no matching platform was found. * - * If emitted during initialization, no matching platform was found. If @ref - * GLFW_PLATFORM is set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of the - * platforms supported by this library binary, except for the Null platform. If set to - * a specific platform, it is either not supported by this library binary or GLFW was not - * able to detect it. + * If emitted during initialization, no matching platform was found. If the @ref + * GLFW_PLATFORM init hint was set to `GLFW_ANY_PLATFORM`, GLFW could not detect any of + * the platforms supported by this library binary, except for the Null platform. If the + * init hint was set to a specific platform, it is either not supported by this library + * binary or GLFW was not able to detect it. * * If emitted by a native access function, GLFW was initialized for a different platform * than the function is for. diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 171abe36..46072920 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -169,7 +169,8 @@ extern "C" { * of the specified monitor, or `NULL` if an [error](@ref error_handling) * occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -186,7 +187,8 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor); * `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -202,7 +204,8 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor); * @return The `HWND` of the specified window, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @remark The `HDC` associated with the window can be queried with the * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc) @@ -228,8 +231,8 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window); * @return The `HGLRC` of the specified window, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref - * GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT. * * @remark The `HDC` associated with the window can be queried with the * [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc) @@ -255,7 +258,8 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window); * @return The `CGDirectDisplayID` of the specified monitor, or * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -271,7 +275,8 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); * @return The `NSWindow` of the specified window, or `nil` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -289,8 +294,8 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window); * @return The `NSOpenGLContext` of the specified window, or `nil` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref - * GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_NO_WINDOW_CONTEXT. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -308,7 +313,8 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window); * @return The `Display` used by GLFW, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -324,7 +330,8 @@ GLFWAPI Display* glfwGetX11Display(void); * @return The `RRCrtc` of the specified monitor, or `None` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -340,7 +347,8 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor); * @return The `RROutput` of the specified monitor, or `None` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -356,7 +364,8 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor); * @return The `Window` of the specified window, or `None` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -371,8 +380,8 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window); * * @param[in] string A UTF-8 encoded string. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * * @pointer_lifetime The specified string is copied before this function * returns. @@ -397,8 +406,8 @@ GLFWAPI void glfwSetX11SelectionString(const char* string); * @return The contents of the selection as a UTF-8 encoded string, or `NULL` * if an [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_PLATFORM_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * * @pointer_lifetime The returned string is allocated and freed by GLFW. You * should not free it yourself. It is valid until the next call to @ref @@ -424,8 +433,8 @@ GLFWAPI const char* glfwGetX11SelectionString(void); * @return The `GLXContext` of the specified window, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref - * GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -441,8 +450,8 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); * @return The `GLXWindow` of the specified window, or `None` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref - * GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -460,7 +469,8 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); * @return The `struct wl_display*` used by GLFW, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -476,7 +486,8 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void); * @return The `struct wl_output*` of the specified monitor, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -492,7 +503,8 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor); * @return The main `struct wl_surface*` of the specified window, or `NULL` if * an [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -529,8 +541,8 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void); * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref - * GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_NO_WINDOW_CONTEXT. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -546,8 +558,8 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window); * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref - * GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_NO_WINDOW_CONTEXT. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -572,8 +584,8 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref - * GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_NO_WINDOW_CONTEXT. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -596,8 +608,8 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref - * GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_NO_WINDOW_CONTEXT. * * @thread_safety This function may be called from any thread. Access is not * synchronized. @@ -613,8 +625,8 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height * @return The `OSMesaContext` of the specified window, or `NULL` if an * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref - * GLFW_NOT_INITIALIZED. + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_NO_WINDOW_CONTEXT. * * @thread_safety This function may be called from any thread. Access is not * synchronized. From 8ff8d675607463cbff7a2c59af6cb9751972c259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 15 Jan 2024 00:23:20 +0100 Subject: [PATCH 015/137] Set timeout for build GH workflow jobs This is in order to catch and stop any malfunctioning job. --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11d111cb..730e82b4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,7 @@ jobs: build-linux-clang: name: Linux (Clang) runs-on: ubuntu-latest + timeout-minutes: 4 env: CC: clang CFLAGS: -Werror @@ -50,6 +51,7 @@ jobs: build-macos-clang: name: macOS (Clang) runs-on: macos-latest + timeout-minutes: 4 env: CFLAGS: -Werror MACOSX_DEPLOYMENT_TARGET: 10.8 @@ -75,6 +77,7 @@ jobs: build-windows-vs2022: name: Windows (VS2022) runs-on: windows-latest + timeout-minutes: 4 env: CFLAGS: /WX steps: From cf29ff2b9d5f2b66f8fc714e14b86989a7aa388d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 15 Jan 2024 00:28:00 +0100 Subject: [PATCH 016/137] Update CODEOWNERS file --- .github/CODEOWNERS | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 018808ba..585b2090 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,8 +1,6 @@ * @elmindreda -src/wl_* @linkmauve - docs/*.css @glfw/webdev docs/*.scss @glfw/webdev docs/*.html @glfw/webdev From d2058526cc9373ac3fff904a0ac6485afdc62478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sat, 13 Jan 2024 22:23:31 +0100 Subject: [PATCH 017/137] Make VS 2013 the oldest tested VS version This is part of removing support for VS versions older than VS 2013. See #2465 for details and feedback. Related to #2465 --- .appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2742949b..523a2199 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -15,10 +15,10 @@ environment: - GENERATOR: MinGW Makefiles BUILD_SHARED_LIBS: OFF CFLAGS: -Werror - - GENERATOR: Visual Studio 10 2010 + - GENERATOR: Visual Studio 12 2013 BUILD_SHARED_LIBS: ON CFLAGS: /WX - - GENERATOR: Visual Studio 10 2010 + - GENERATOR: Visual Studio 12 2013 BUILD_SHARED_LIBS: OFF CFLAGS: /WX matrix: @@ -35,7 +35,7 @@ for: - matrix: only: - - GENERATOR: Visual Studio 10 2010 + - GENERATOR: Visual Studio 12 2013 build_script: - cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% - cmake --build build --target glfw From d107e497a917c384f16529d9e88959ca7a605d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 15 Jan 2024 19:53:20 +0100 Subject: [PATCH 018/137] Remove superfluous CMake flag in AppVeyor build The source directory already defaults to the current directory. --- .appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 523a2199..c58911cc 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -30,14 +30,14 @@ for: - GENERATOR: MinGW Makefiles 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 -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% - cmake --build build - matrix: only: - GENERATOR: Visual Studio 12 2013 build_script: - - cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% + - cmake -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% - cmake --build build --target glfw notifications: - provider: Email From ba796ec9c6a36fc60947b50bb5b86f6e63bc612e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 15 Jan 2024 19:28:25 +0100 Subject: [PATCH 019/137] Document VS 2013 as minimum VS version This is part of removing support for VS versions older than VS 2013. See #2465 for details and feedback. Related to #2465 --- README.md | 2 ++ docs/compile.dox | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index fe5d060a..886ca66f 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ more information. ## System requirements +GLFW is written in C99 and does not support Visual Studio 2012 or earlier. + GLFW supports Windows XP and later and macOS 10.8 and later. Linux and other Unix-like systems running the X Window System are supported even without a desktop environment or modern extensions, although some features require diff --git a/docs/compile.dox b/docs/compile.dox index 4968af40..ecf199a5 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -7,6 +7,8 @@ This is about compiling the GLFW library itself. For information on how to build applications that use GLFW, see @ref build_guide. +GLFW uses some C99 features and does not support Visual Studio 2012 and earlier. + @section compile_cmake Using CMake From 8e6c8d7effc54f8aecd30eda17069588298f4ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 11 Jan 2024 21:32:56 +0100 Subject: [PATCH 020/137] Remove reminders to use C89 for some source files This is part of removing support for VS versions older than VS 2013. See #2465 for details and feedback. Related to #2465 --- src/CMakeLists.txt | 11 ----------- src/cocoa_time.c | 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/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/platform.c | 2 -- src/posix_module.c | 2 -- src/posix_poll.c | 2 -- src/posix_poll.h | 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_module.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 -- 37 files changed, 83 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 42f4e014..c49b31c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -237,17 +237,6 @@ if (UNIX AND NOT APPLE) endif() endif() -# Make GCC warn about declarations that VS 2010 and 2012 won't accept for all -# source files that VS will build (Clang ignores this because we set -std=c99) -if (CMAKE_C_COMPILER_ID STREQUAL "GNU") - set_source_files_properties(context.c init.c input.c monitor.c platform.c vulkan.c - window.c null_init.c null_joystick.c null_monitor.c - null_window.c win32_init.c win32_joystick.c win32_module.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() - if (WIN32) if (GLFW_USE_HYBRID_HPG) target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG) diff --git a/src/cocoa_time.c b/src/cocoa_time.c index 8da367aa..d56f145f 100644 --- a/src/cocoa_time.c +++ b/src/cocoa_time.c @@ -23,8 +23,6 @@ // 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 f8610e1e..cc1fac4f 100644 --- a/src/context.c +++ b/src/context.c @@ -24,8 +24,6 @@ // 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 6e997b11..ef65dd35 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -24,8 +24,6 @@ // 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 f3f4b3ec..7082682b 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -24,8 +24,6 @@ // 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 06dbb3f2..2db542f7 100644 --- a/src/init.c +++ b/src/init.c @@ -24,8 +24,6 @@ // distribution. // //======================================================================== -// Please use C89 style variable declarations in this file because VS 2010 -//======================================================================== #include "internal.h" diff --git a/src/input.c b/src/input.c index 8b7ef29c..b5bb69d6 100644 --- a/src/input.c +++ b/src/input.c @@ -24,8 +24,6 @@ // distribution. // //======================================================================== -// Please use C89 style variable declarations in this file because VS 2010 -//======================================================================== #include "internal.h" #include "mappings.h" diff --git a/src/linux_joystick.c b/src/linux_joystick.c index 78d867eb..c67f3d77 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -24,8 +24,6 @@ // 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 6429493b..61cdcb8f 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -24,8 +24,6 @@ // distribution. // //======================================================================== -// Please use C89 style variable declarations in this file because VS 2010 -//======================================================================== #include "internal.h" diff --git a/src/null_init.c b/src/null_init.c index 7236c98c..34ddc04a 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -24,8 +24,6 @@ // 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 1fe50721..ec1f6b55 100644 --- a/src/null_joystick.c +++ b/src/null_joystick.c @@ -23,8 +23,6 @@ // 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 63a1cd20..787fde71 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -24,8 +24,6 @@ // 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 e0bbb3b6..c2aafbad 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -24,8 +24,6 @@ // 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 38adabbc..a3f1a884 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -24,8 +24,6 @@ // distribution. // //======================================================================== -// Please use C89 style variable declarations in this file because VS 2010 -//======================================================================== #include #include diff --git a/src/platform.c b/src/platform.c index c5966ae7..e666ccd8 100644 --- a/src/platform.c +++ b/src/platform.c @@ -24,8 +24,6 @@ // distribution. // //======================================================================== -// Please use C89 style variable declarations in this file because VS 2010 -//======================================================================== #include "internal.h" diff --git a/src/posix_module.c b/src/posix_module.c index ba5024a3..7d81c672 100644 --- a/src/posix_module.c +++ b/src/posix_module.c @@ -23,8 +23,6 @@ // 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_poll.c b/src/posix_poll.c index a5016a13..b53e36e8 100644 --- a/src/posix_poll.c +++ b/src/posix_poll.c @@ -23,8 +23,6 @@ // 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/posix_poll.h b/src/posix_poll.h index 1effd1cd..4bdd2448 100644 --- a/src/posix_poll.h +++ b/src/posix_poll.h @@ -23,8 +23,6 @@ // distribution. // //======================================================================== -// It is fine to use C99 in this file because it will not be built with VS -//======================================================================== #include diff --git a/src/posix_thread.c b/src/posix_thread.c index 4ce55526..3c355a53 100644 --- a/src/posix_thread.c +++ b/src/posix_thread.c @@ -24,8 +24,6 @@ // 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 caed678e..a1724084 100644 --- a/src/posix_time.c +++ b/src/posix_time.c @@ -24,8 +24,6 @@ // 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 64a4650f..d9fabdea 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -24,8 +24,6 @@ // 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 08c499ff..65d758af 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -24,8 +24,6 @@ // 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 ef2615f1..4cb01adb 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -24,8 +24,6 @@ // 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 eae44edf..59389a90 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -24,8 +24,6 @@ // distribution. // //======================================================================== -// Please use C89 style variable declarations in this file because VS 2010 -//======================================================================== #include "internal.h" diff --git a/src/win32_module.c b/src/win32_module.c index 9c2b6d24..47c8dff6 100644 --- a/src/win32_module.c +++ b/src/win32_module.c @@ -23,8 +23,6 @@ // 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 2935ac28..13f7bfe7 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -24,8 +24,6 @@ // 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 db997915..212e666c 100644 --- a/src/win32_thread.c +++ b/src/win32_thread.c @@ -24,8 +24,6 @@ // 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 fcfe2005..a38e15dd 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -24,8 +24,6 @@ // 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 28f8d585..f7feb32d 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -24,8 +24,6 @@ // 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 1c8519ff..1117df2f 100644 --- a/src/window.c +++ b/src/window.c @@ -25,8 +25,6 @@ // 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 5790cfc4..a4692b52 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -23,8 +23,6 @@ // 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 b56f3dfb..df64f603 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -23,8 +23,6 @@ // 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 86b5b0fd..76c6a763 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -23,8 +23,6 @@ // 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 a0100f2f..c90b593c 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -24,8 +24,6 @@ // 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 3183630b..ae626643 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -24,8 +24,6 @@ // 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 7da9b965..3c76d3a9 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -24,8 +24,6 @@ // 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 a516af00..6b8dfcac 100644 --- a/src/xkb_unicode.c +++ b/src/xkb_unicode.c @@ -24,8 +24,6 @@ // distribution. // //======================================================================== -// It is fine to use C99 in this file because it will not be built with VS -//======================================================================== #include "internal.h" From c8521b7fda997a9d8c0a1e03ede3cf9f942d3d2e Mon Sep 17 00:00:00 2001 From: Hilderin <81109165+Hilderin@users.noreply.github.com> Date: Sun, 28 Jan 2024 12:08:27 -0500 Subject: [PATCH 021/137] Win 32: Fix disabled cursor mode when connected over RDP Fixes #1276 Based on PR #1279 by @Pokechu22 Co-authored-by: Pokechu22 <8334194+Pokechu22@users.noreply.github.com> --- CONTRIBUTORS.md | 2 ++ README.md | 1 + src/win32_init.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ src/win32_platform.h | 5 +++++ src/win32_window.c | 38 +++++++++++++++++++++++++++++++---- 5 files changed, 90 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 6741d82f..5346cf69 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -279,6 +279,8 @@ video tutorials. - Jonas Ådahl - Lasse Öörni - Leonard König + - Pokechu22 + - Guillaume Lebrun - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/README.md b/README.md index 886ca66f..7515f327 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408) - [Win32] Bugfix: Fix pkg-config for dynamic library on Windows (#2386, #2420) - [Win32] Bugfix: XInput could reportedly provide invalid DPad bit masks (#2291) + - [Win32] Bugfix: Disabled cursor mode doesn't work right when connected over RDP (#1276) - [Win32] Bugfix: Rapid clipboard calls could fail due to Clipboard History - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle diff --git a/src/win32_init.c b/src/win32_init.c index 4cb01adb..4cd17ec1 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -430,6 +430,47 @@ static GLFWbool createHelperWindow(void) return GLFW_TRUE; } +// Creates the blank cursor +// +static void createBlankCursor(void) +{ + // HACK: Create a transparent cursor as using the NULL cursor breaks + // using SetCursorPos when connected over RDP + int cursorWidth = GetSystemMetrics(SM_CXCURSOR); + int cursorHeight = GetSystemMetrics(SM_CYCURSOR); + unsigned char* andMask = calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); + unsigned char* xorMask = calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); + + if (andMask != NULL && xorMask != NULL) { + + memset(andMask, 0xFF, (size_t)(cursorWidth * cursorHeight / 8)); + + // Cursor creation might fail, but that's fine as we get NULL in that case, + // which serves as an acceptable fallback blank cursor (other than on RDP) + _glfw.win32.blankCursor = CreateCursor(NULL, 0, 0, cursorWidth, cursorHeight, andMask, xorMask); + + free(andMask); + free(xorMask); + } + +} + +// Initialize for remote sessions +// +static void initRemoteSession(void) +{ + //Check if the current progress was started with Remote Desktop. + _glfw.win32.isRemoteSession = GetSystemMetrics(SM_REMOTESESSION) > 0; + + // With Remote desktop, we need to create a blank cursor because of the cursor is Set to NULL + // if cannot be moved to center in capture mode. If not Remote Desktop win32.blankCursor stays NULL + // and will perform has before (normal). + if (_glfw.win32.isRemoteSession) + { + createBlankCursor(); + } + +} ////////////////////////////////////////////////////////////////////////// ////// GLFW internal API ////// @@ -699,12 +740,19 @@ int _glfwInitWin32(void) if (!createHelperWindow()) return GLFW_FALSE; + //Some hacks are needed to support Remote Desktop... + initRemoteSession(); + _glfwPollMonitorsWin32(); return GLFW_TRUE; } void _glfwTerminateWin32(void) { + + if (_glfw.win32.blankCursor) + DestroyCursor(_glfw.win32.blankCursor); + if (_glfw.win32.deviceNotificationHandle) UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle); diff --git a/src/win32_platform.h b/src/win32_platform.h index 82b34bb9..5a817d05 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -430,6 +430,7 @@ typedef struct _GLFWwindowWin32 // The last received cursor position, regardless of source int lastCursorPosX, lastCursorPosY; + // The last received high surrogate when decoding pairs of UTF-16 messages WCHAR highSurrogate; } _GLFWwindowWin32; @@ -457,6 +458,10 @@ typedef struct _GLFWlibraryWin32 RAWINPUT* rawInput; int rawInputSize; UINT mouseTrailSize; + // Indicate if the process was started behind Remote Destop + BOOL isRemoteSession; + // An invisible cursor, needed for special cases (see WM_INPUT handler) + HCURSOR blankCursor; struct { HINSTANCE instance; diff --git a/src/win32_window.c b/src/win32_window.c index f7feb32d..6697f4e4 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -232,7 +232,10 @@ static void updateCursorImage(_GLFWwindow* window) SetCursor(LoadCursorW(NULL, IDC_ARROW)); } else - SetCursor(NULL); + //Connected via Remote Desktop, NULL cursor will present SetCursorPos the move the cursor. + //using a blank cursor fix that. + //When not via Remote Desktop, win32.blankCursor should be NULL + SetCursor(_glfw.win32.blankCursor); } // Sets the cursor clip rect to the window content area @@ -897,6 +900,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l HRAWINPUT ri = (HRAWINPUT) lParam; RAWINPUT* data = NULL; int dx, dy; + int width, height; + POINT pos; if (_glfw.win32.disabledCursorWindow != window) break; @@ -923,9 +928,30 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l data = _glfw.win32.rawInput; if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE) - { - dx = data->data.mouse.lLastX - window->win32.lastCursorPosX; - dy = data->data.mouse.lLastY - window->win32.lastCursorPosY; + { + if (_glfw.win32.isRemoteSession) + { + //Remote Desktop Mode... + // As per https://github.com/Microsoft/DirectXTK/commit/ef56b63f3739381e451f7a5a5bd2c9779d2a7555 + // MOUSE_MOVE_ABSOLUTE is a range from 0 through 65535, based on the screen size. + // As far as I can tell, absolute mode only occurs over RDP though. + width = GetSystemMetrics((data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); + height = GetSystemMetrics((data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); + + pos.x = (int)((data->data.mouse.lLastX / 65535.0f) * width); + pos.y = (int)((data->data.mouse.lLastY / 65535.0f) * height); + ScreenToClient(window->win32.handle, &pos); + + dx = pos.x - window->win32.lastCursorPosX; + dy = pos.y - window->win32.lastCursorPosY; + } + else + { + //Normal mode... We should have the right absolute coords in data.mouse + dx = data->data.mouse.lLastX - window->win32.lastCursorPosX; + dy = data->data.mouse.lLastY - window->win32.lastCursorPosY; + } + } else { @@ -1432,11 +1458,13 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.transparent = GLFW_TRUE; } + _glfwGetWindowSizeWin32(window, &window->win32.width, &window->win32.height); return GLFW_TRUE; } + GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, @@ -1525,6 +1553,7 @@ void _glfwDestroyWindowWin32(_GLFWwindow* window) if (window->win32.smallIcon) DestroyIcon(window->win32.smallIcon); + } void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title) @@ -2102,6 +2131,7 @@ void _glfwPollEventsWin32(void) // NOTE: Re-center the cursor only if it has moved since the last call, // to avoid breaking glfwWaitEvents with WM_MOUSEMOVE + // The re-center is required in order to prevent the mouse cursor stopping at the edges of the screen. if (window->win32.lastCursorPosX != width / 2 || window->win32.lastCursorPosY != height / 2) { From 7321b56cad775682b22de1bb7fe8fc54cc76fa77 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sun, 28 Jan 2024 17:18:11 +0000 Subject: [PATCH 022/137] Reorder credit --- CONTRIBUTORS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 5346cf69..0bfa620d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -120,6 +120,7 @@ video tutorials. - Rokas Kupstys - Konstantin Käfer - Eric Larson + - Guillaume Lebrun - Francis Lecavalier - Jong Won Lee - Robin Leffmann @@ -192,6 +193,7 @@ video tutorials. - Stanislav Podgorskiy - Konstantin Podsvirov - Nathan Poirier + - Pokechu22 - Alexandre Pretyman - Pablo Prietz - przemekmirek @@ -279,8 +281,6 @@ video tutorials. - Jonas Ådahl - Lasse Öörni - Leonard König - - Pokechu22 - - Guillaume Lebrun - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement From 1de78b2ff98b0130f354ba02cca3ed329ea57614 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sun, 28 Jan 2024 17:24:14 +0000 Subject: [PATCH 023/137] Cleanup --- src/win32_init.c | 3 --- src/win32_platform.h | 1 - src/win32_window.c | 4 ---- 3 files changed, 8 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index 4cd17ec1..a44e8145 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -452,7 +452,6 @@ static void createBlankCursor(void) free(andMask); free(xorMask); } - } // Initialize for remote sessions @@ -469,7 +468,6 @@ static void initRemoteSession(void) { createBlankCursor(); } - } ////////////////////////////////////////////////////////////////////////// @@ -749,7 +747,6 @@ int _glfwInitWin32(void) void _glfwTerminateWin32(void) { - if (_glfw.win32.blankCursor) DestroyCursor(_glfw.win32.blankCursor); diff --git a/src/win32_platform.h b/src/win32_platform.h index 5a817d05..1db31584 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -430,7 +430,6 @@ typedef struct _GLFWwindowWin32 // The last received cursor position, regardless of source int lastCursorPosX, lastCursorPosY; - // The last received high surrogate when decoding pairs of UTF-16 messages WCHAR highSurrogate; } _GLFWwindowWin32; diff --git a/src/win32_window.c b/src/win32_window.c index 6697f4e4..db3bed6e 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -951,7 +951,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l dx = data->data.mouse.lLastX - window->win32.lastCursorPosX; dy = data->data.mouse.lLastY - window->win32.lastCursorPosY; } - } else { @@ -1458,13 +1457,11 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.transparent = GLFW_TRUE; } - _glfwGetWindowSizeWin32(window, &window->win32.width, &window->win32.height); return GLFW_TRUE; } - GLFWbool _glfwCreateWindowWin32(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, @@ -1553,7 +1550,6 @@ void _glfwDestroyWindowWin32(_GLFWwindow* window) if (window->win32.smallIcon) DestroyIcon(window->win32.smallIcon); - } void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title) From 996826eec64dc38b360729debcbc9460367acc7b Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sun, 28 Jan 2024 17:30:15 +0000 Subject: [PATCH 024/137] Reorder and add details to changelog entry --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7515f327..3bb5af95 100644 --- a/README.md +++ b/README.md @@ -236,8 +236,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408) - [Win32] Bugfix: Fix pkg-config for dynamic library on Windows (#2386, #2420) - [Win32] Bugfix: XInput could reportedly provide invalid DPad bit masks (#2291) - - [Win32] Bugfix: Disabled cursor mode doesn't work right when connected over RDP (#1276) - [Win32] Bugfix: Rapid clipboard calls could fail due to Clipboard History + - [Win32] Bugfix: Disabled cursor mode doesn't work right when connected over RDP (#1276,#1279,#2431) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) From d79afa805510b45c823e7ca979a6486278dca41d Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sun, 28 Jan 2024 17:45:03 +0000 Subject: [PATCH 025/137] Win32: Minor changes to disabled cursor fix over RDP - Use _glfw_calloc and _glfw_free - Exit from _glfwInitWin32 with error if we fail to create a blank cursor on a remote session --- src/win32_init.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index a44e8145..739c9c33 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -438,8 +438,8 @@ static void createBlankCursor(void) // using SetCursorPos when connected over RDP int cursorWidth = GetSystemMetrics(SM_CXCURSOR); int cursorHeight = GetSystemMetrics(SM_CYCURSOR); - unsigned char* andMask = calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); - unsigned char* xorMask = calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); + unsigned char* andMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); + unsigned char* xorMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); if (andMask != NULL && xorMask != NULL) { @@ -449,8 +449,8 @@ static void createBlankCursor(void) // which serves as an acceptable fallback blank cursor (other than on RDP) _glfw.win32.blankCursor = CreateCursor(NULL, 0, 0, cursorWidth, cursorHeight, andMask, xorMask); - free(andMask); - free(xorMask); + _glfw_free(andMask); + _glfw_free(xorMask); } } @@ -740,6 +740,12 @@ int _glfwInitWin32(void) //Some hacks are needed to support Remote Desktop... initRemoteSession(); + if (_glfw.win32.isRemoteSession && _glfw.win32.blankCursor == NULL ) + { + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, + "Win32: Failed to create blank cursor for remote session."); + return GLFW_FALSE; + } _glfwPollMonitorsWin32(); return GLFW_TRUE; From 9afbcb442bc1e9e173b0b76ba4f7290b137b4d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 16 Jan 2024 22:59:35 +0100 Subject: [PATCH 026/137] Wayland: Clean up pointer axis handler --- src/wl_window.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 76c6a763..8d8f8ab1 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1501,24 +1501,14 @@ static void pointerHandleAxis(void* userData, wl_fixed_t value) { _GLFWwindow* window = _glfw.wl.pointerFocus; - double x = 0.0, y = 0.0; - // Wayland scroll events are in pointer motion coordinate space (think two - // finger scroll). The factor 10 is commonly used to convert to "scroll - // step means 1.0. - const double scrollFactor = 1.0 / 10.0; - if (!window) return; - assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL || - axis == WL_POINTER_AXIS_VERTICAL_SCROLL); - + // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) - x = -wl_fixed_to_double(value) * scrollFactor; + _glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0); else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) - y = -wl_fixed_to_double(value) * scrollFactor; - - _glfwInputScroll(window, x, y); + _glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0); } static const struct wl_pointer_listener pointerListener = From c339dfc63d22248c51ed149cc336ff0661d7d393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Dec 2023 15:37:01 +0100 Subject: [PATCH 027/137] Update changelog for 3.4 release This adds some missing entries and splits them all into what has already been released and what hasn't. --- README.md | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 3bb5af95..fd759897 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for information on what to include when reporting a bug. -## Changelog +## Changelog since 3.3.9 - Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958) - Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, @@ -155,6 +155,7 @@ information on what to include when reporting a bug. values to select ANGLE backend (#1380) - Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan surface extension (#1793) + - Added `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - Added `GLFW_NATIVE_INCLUDE_NONE` for disabling inclusion of native headers (#1348) - Added `GLFW_BUILD_WIN32` CMake option for enabling Win32 support (#1958) - Added `GLFW_BUILD_COCOA` CMake option for enabling Cocoa support (#1958) @@ -167,10 +168,33 @@ information on what to include when reporting a bug. - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 - Updated gamepad mappings from upstream - - Disabled tests and examples by default when built as a CMake subdirectory - Renamed `GLFW_USE_WAYLAND` CMake option to `GLFW_BUILD_WAYLAND` (#1958) + - Disabled tests and examples by default when built as a CMake subdirectory - Removed `GLFW_USE_OSMESA` CMake option enabling the Null platform (#1958) - Removed CMake generated configuration header + - [Win32] Added a version info resource to the GLFW DLL + - [Win32] Made hidden helper window use its own window class + - [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user + - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) + - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread + would abort (#1649) + - [Wayland] Added dynamic loading of all Wayland libraries + - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled + - [X11] Bugfix: Termination would segfault if the IM had been destroyed + - [X11] Bugfix: Any IM started after initialization would not be detected + - [POSIX] Removed use of deprecated function `gettimeofday` + - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled + - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) + - [NSGL] Removed enforcement of forward-compatible flag for core contexts + - [EGL] Added platform selection via the `EGL_EXT_platform_base` extension + (#442) + - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension + (#1380) + + +## Changelog since 3.3 + + - Added `GLFW_WAYLAND_LIBDECOR` init hint for disabling libdecor support (#1639,#1693) - 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) @@ -187,10 +211,6 @@ information on what to include when reporting a bug. - Bugfix: `glfwGetJoystickUserPointer` returned `NULL` during disconnection (#2092) - Bugfix: `glfwGetKeyScancode` returned `0` on error when initialized instead of `-1` - Bugfix: Failure to make a newly created context current could cause segfault (#2327) - - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access - to the window menu - - [Win32] Added a version info resource to the GLFW DLL - - [Win32] Made hidden helper window use its own window class - [Win32] Disabled framebuffer transparency on Windows 7 when DWM windows are opaque (#1512) - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused @@ -217,7 +237,6 @@ information on what to include when reporting a bug. - [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or later (#1783,#1796) - [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874) - - [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user - [Win32] Bugfix: Content scale queries could fail silently (#1615) - [Win32] Bugfix: Content scales could have garbage values if monitor was recently disconnected (#1615) @@ -240,7 +259,6 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Disabled cursor mode doesn't work right when connected over RDP (#1276,#1279,#2431) - [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] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169) - [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency (#1786) @@ -251,8 +269,6 @@ information on what to include when reporting a bug. (#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) - [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16 (#1635) - [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays @@ -296,8 +312,6 @@ 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 - [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) @@ -325,7 +339,6 @@ information on what to include when reporting a bug. - [X11] Bugfix: A malformed response during selection transfer could cause a segfault - [X11] Bugfix: Some calls would reset Xlib to the default error handler (#2108) - [Wayland] Added improved fallback window decorations via libdecor (#1639,#1693) - - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Added support for key names via xkbcommon - [Wayland] Added support for file path drop events (#2040) - [Wayland] Added support for more human-readable monitor names where available @@ -333,7 +346,6 @@ information on what to include when reporting a bug. `EGL_EXT_present_opaque` (#1895) - [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) - [Wayland] Bugfix: Retrieving partial framebuffer size would segfault - [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms @@ -398,21 +410,13 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450) - [Wayland] Bugfix: Joysticks connected after `glfwInit` were not detected (#2198) - [Wayland] Bugfix: Fallback decorations emitted `GLFW_CURSOR_UNAVAILABLE` errors - - [POSIX] Removed use of deprecated function `gettimeofday` - - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043) - [Linux] Bugfix: A small amount of memory could leak if initialization failed (#2229) - - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) - - [NSGL] Removed enforcement of forward-compatible flag for core contexts - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer macOS versions (#1442) - [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483) - [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused a duplicate definition warning (#1840) - - [EGL] Added platform selection via the `EGL_EXT_platform_base` extension - (#442) - - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension - (#1380) - [EGL] Added loading of glvnd `libOpenGL.so.0` where available for OpenGL - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) - [EGL] Bugfix: Setting `GLFW_CONTEXT_DEBUG` caused creation to fail (#2348) From d81fcb93f185a2dc9b9872cbfc51f5498b8386ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 24 Jan 2024 17:06:15 +0100 Subject: [PATCH 028/137] Clarify event test reporting of keys Reshuffled line to group key-related items together. Omitted key code output for unknown keys to put focus on the (lack of) name. --- tests/events.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/tests/events.c b/tests/events.c index 60d4fc89..fdc3c199 100644 --- a/tests/events.c +++ b/tests/events.c @@ -400,24 +400,34 @@ static void scroll_callback(GLFWwindow* window, double x, double y) static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { Slot* slot = glfwGetWindowUserPointer(window); - const char* name = glfwGetKeyName(key, scancode); - if (name) + if (key == GLFW_KEY_UNKNOWN) { - printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (%s) (with%s) was %s\n", - counter++, slot->number, glfwGetTime(), key, scancode, - get_key_name(key), - name, - get_mods_name(mods), - get_action_name(action)); + printf("%08x to %i at %0.3f: Key (%s) Scancode 0x%04x (with%s) was %s\n", + counter++, slot->number, glfwGetTime(), + get_key_name(key), scancode, + get_mods_name(mods), + get_action_name(action)); } else { - printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n", - counter++, slot->number, glfwGetTime(), key, scancode, - get_key_name(key), - get_mods_name(mods), - get_action_name(action)); + const char* name = glfwGetKeyName(key, scancode); + if (name) + { + printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x Name %s (with%s) was %s\n", + counter++, slot->number, glfwGetTime(), + key, get_key_name(key), scancode, name, + get_mods_name(mods), + get_action_name(action)); + } + else + { + printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x (with%s) was %s\n", + counter++, slot->number, glfwGetTime(), + key, get_key_name(key), scancode, + get_mods_name(mods), + get_action_name(action)); + } } if (action != GLFW_PRESS) From bbf661ca381b2319cebf1d1d4d97d1841699296a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 11 Jan 2024 22:22:31 +0100 Subject: [PATCH 029/137] Replace comments with designated initializers We can finally have the compiler verify that the values go to the correct struct member. With this commit GLFW no longer compiles with Visual Studio 2012 or earlier. If you must compile GLFW on Windows XP, check out MinGW-w64. Fixes #2465 --- src/init.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/init.c b/src/init.c index 2db542f7..2b903146 100644 --- a/src/init.c +++ b/src/init.c @@ -49,19 +49,22 @@ static GLFWerrorfun _glfwErrorCallback; static GLFWallocator _glfwInitAllocator; static _GLFWinitconfig _glfwInitHints = { - GLFW_TRUE, // hat buttons - GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend - GLFW_ANY_PLATFORM, // preferred platform - NULL, // vkGetInstanceProcAddr function + .hatButtons = GLFW_TRUE, + .angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE, + .platformID = GLFW_ANY_PLATFORM, + .vulkanLoader = NULL, + .ns = { - GLFW_TRUE, // macOS menu bar - GLFW_TRUE // macOS bundle chdir + .menubar = GLFW_TRUE, + .chdir = GLFW_TRUE }, + .x11 = { - GLFW_TRUE, // X11 XCB Vulkan surface + .xcbVulkanSurface = GLFW_TRUE, }, + .wl = { - GLFW_WAYLAND_PREFER_LIBDECOR // Wayland libdecor mode + .libdecorMode = GLFW_WAYLAND_PREFER_LIBDECOR }, }; From 7e2470d343df1341485cb7f6d109a25f55c4e1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 11 Jan 2024 22:26:19 +0100 Subject: [PATCH 030/137] Use designated initializers for platform structs This should make platform struct initializers slightly more resistant to merge mistakes. --- src/cocoa_init.m | 144 ++++++++++++++++++++++---------------------- src/null_init.c | 144 ++++++++++++++++++++++---------------------- src/win32_init.c | 144 ++++++++++++++++++++++---------------------- src/wl_init.c | 154 +++++++++++++++++++++++------------------------ src/x11_init.c | 154 +++++++++++++++++++++++------------------------ 5 files changed, 370 insertions(+), 370 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index b3831df1..6baf6b3f 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -495,78 +495,78 @@ GLFWbool _glfwConnectCocoa(int platformID, _GLFWplatform* platform) { const _GLFWplatform cocoa = { - GLFW_PLATFORM_COCOA, - _glfwInitCocoa, - _glfwTerminateCocoa, - _glfwGetCursorPosCocoa, - _glfwSetCursorPosCocoa, - _glfwSetCursorModeCocoa, - _glfwSetRawMouseMotionCocoa, - _glfwRawMouseMotionSupportedCocoa, - _glfwCreateCursorCocoa, - _glfwCreateStandardCursorCocoa, - _glfwDestroyCursorCocoa, - _glfwSetCursorCocoa, - _glfwGetScancodeNameCocoa, - _glfwGetKeyScancodeCocoa, - _glfwSetClipboardStringCocoa, - _glfwGetClipboardStringCocoa, - _glfwInitJoysticksCocoa, - _glfwTerminateJoysticksCocoa, - _glfwPollJoystickCocoa, - _glfwGetMappingNameCocoa, - _glfwUpdateGamepadGUIDCocoa, - _glfwFreeMonitorCocoa, - _glfwGetMonitorPosCocoa, - _glfwGetMonitorContentScaleCocoa, - _glfwGetMonitorWorkareaCocoa, - _glfwGetVideoModesCocoa, - _glfwGetVideoModeCocoa, - _glfwGetGammaRampCocoa, - _glfwSetGammaRampCocoa, - _glfwCreateWindowCocoa, - _glfwDestroyWindowCocoa, - _glfwSetWindowTitleCocoa, - _glfwSetWindowIconCocoa, - _glfwGetWindowPosCocoa, - _glfwSetWindowPosCocoa, - _glfwGetWindowSizeCocoa, - _glfwSetWindowSizeCocoa, - _glfwSetWindowSizeLimitsCocoa, - _glfwSetWindowAspectRatioCocoa, - _glfwGetFramebufferSizeCocoa, - _glfwGetWindowFrameSizeCocoa, - _glfwGetWindowContentScaleCocoa, - _glfwIconifyWindowCocoa, - _glfwRestoreWindowCocoa, - _glfwMaximizeWindowCocoa, - _glfwShowWindowCocoa, - _glfwHideWindowCocoa, - _glfwRequestWindowAttentionCocoa, - _glfwFocusWindowCocoa, - _glfwSetWindowMonitorCocoa, - _glfwWindowFocusedCocoa, - _glfwWindowIconifiedCocoa, - _glfwWindowVisibleCocoa, - _glfwWindowMaximizedCocoa, - _glfwWindowHoveredCocoa, - _glfwFramebufferTransparentCocoa, - _glfwGetWindowOpacityCocoa, - _glfwSetWindowResizableCocoa, - _glfwSetWindowDecoratedCocoa, - _glfwSetWindowFloatingCocoa, - _glfwSetWindowOpacityCocoa, - _glfwSetWindowMousePassthroughCocoa, - _glfwPollEventsCocoa, - _glfwWaitEventsCocoa, - _glfwWaitEventsTimeoutCocoa, - _glfwPostEmptyEventCocoa, - _glfwGetEGLPlatformCocoa, - _glfwGetEGLNativeDisplayCocoa, - _glfwGetEGLNativeWindowCocoa, - _glfwGetRequiredInstanceExtensionsCocoa, - _glfwGetPhysicalDevicePresentationSupportCocoa, - _glfwCreateWindowSurfaceCocoa, + .platformID = GLFW_PLATFORM_COCOA, + .init = _glfwInitCocoa, + .terminate = _glfwTerminateCocoa, + .getCursorPos = _glfwGetCursorPosCocoa, + .setCursorPos = _glfwSetCursorPosCocoa, + .setCursorMode = _glfwSetCursorModeCocoa, + .setRawMouseMotion = _glfwSetRawMouseMotionCocoa, + .rawMouseMotionSupported = _glfwRawMouseMotionSupportedCocoa, + .createCursor = _glfwCreateCursorCocoa, + .createStandardCursor = _glfwCreateStandardCursorCocoa, + .destroyCursor = _glfwDestroyCursorCocoa, + .setCursor = _glfwSetCursorCocoa, + .getScancodeName = _glfwGetScancodeNameCocoa, + .getKeyScancode = _glfwGetKeyScancodeCocoa, + .setClipboardString = _glfwSetClipboardStringCocoa, + .getClipboardString = _glfwGetClipboardStringCocoa, + .initJoysticks = _glfwInitJoysticksCocoa, + .terminateJoysticks = _glfwTerminateJoysticksCocoa, + .pollJoystick = _glfwPollJoystickCocoa, + .getMappingName = _glfwGetMappingNameCocoa, + .updateGamepadGUID = _glfwUpdateGamepadGUIDCocoa, + .freeMonitor = _glfwFreeMonitorCocoa, + .getMonitorPos = _glfwGetMonitorPosCocoa, + .getMonitorContentScale = _glfwGetMonitorContentScaleCocoa, + .getMonitorWorkarea = _glfwGetMonitorWorkareaCocoa, + .getVideoModes = _glfwGetVideoModesCocoa, + .getVideoMode = _glfwGetVideoModeCocoa, + .getGammaRamp = _glfwGetGammaRampCocoa, + .setGammaRamp = _glfwSetGammaRampCocoa, + .createWindow = _glfwCreateWindowCocoa, + .destroyWindow = _glfwDestroyWindowCocoa, + .setWindowTitle = _glfwSetWindowTitleCocoa, + .setWindowIcon = _glfwSetWindowIconCocoa, + .getWindowPos = _glfwGetWindowPosCocoa, + .setWindowPos = _glfwSetWindowPosCocoa, + .getWindowSize = _glfwGetWindowSizeCocoa, + .setWindowSize = _glfwSetWindowSizeCocoa, + .setWindowSizeLimits = _glfwSetWindowSizeLimitsCocoa, + .setWindowAspectRatio = _glfwSetWindowAspectRatioCocoa, + .getFramebufferSize = _glfwGetFramebufferSizeCocoa, + .getWindowFrameSize = _glfwGetWindowFrameSizeCocoa, + .getWindowContentScale = _glfwGetWindowContentScaleCocoa, + .iconifyWindow = _glfwIconifyWindowCocoa, + .restoreWindow = _glfwRestoreWindowCocoa, + .maximizeWindow = _glfwMaximizeWindowCocoa, + .showWindow = _glfwShowWindowCocoa, + .hideWindow = _glfwHideWindowCocoa, + .requestWindowAttention = _glfwRequestWindowAttentionCocoa, + .focusWindow = _glfwFocusWindowCocoa, + .setWindowMonitor = _glfwSetWindowMonitorCocoa, + .windowFocused = _glfwWindowFocusedCocoa, + .windowIconified = _glfwWindowIconifiedCocoa, + .windowVisible = _glfwWindowVisibleCocoa, + .windowMaximized = _glfwWindowMaximizedCocoa, + .windowHovered = _glfwWindowHoveredCocoa, + .framebufferTransparent = _glfwFramebufferTransparentCocoa, + .getWindowOpacity = _glfwGetWindowOpacityCocoa, + .setWindowResizable = _glfwSetWindowResizableCocoa, + .setWindowDecorated = _glfwSetWindowDecoratedCocoa, + .setWindowFloating = _glfwSetWindowFloatingCocoa, + .setWindowOpacity = _glfwSetWindowOpacityCocoa, + .setWindowMousePassthrough = _glfwSetWindowMousePassthroughCocoa, + .pollEvents = _glfwPollEventsCocoa, + .waitEvents = _glfwWaitEventsCocoa, + .waitEventsTimeout = _glfwWaitEventsTimeoutCocoa, + .postEmptyEvent = _glfwPostEmptyEventCocoa, + .getEGLPlatform = _glfwGetEGLPlatformCocoa, + .getEGLNativeDisplay = _glfwGetEGLNativeDisplayCocoa, + .getEGLNativeWindow = _glfwGetEGLNativeWindowCocoa, + .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsCocoa, + .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportCocoa, + .createWindowSurface = _glfwCreateWindowSurfaceCocoa }; *platform = cocoa; diff --git a/src/null_init.c b/src/null_init.c index 34ddc04a..88940fcd 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -39,78 +39,78 @@ GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform) { const _GLFWplatform null = { - GLFW_PLATFORM_NULL, - _glfwInitNull, - _glfwTerminateNull, - _glfwGetCursorPosNull, - _glfwSetCursorPosNull, - _glfwSetCursorModeNull, - _glfwSetRawMouseMotionNull, - _glfwRawMouseMotionSupportedNull, - _glfwCreateCursorNull, - _glfwCreateStandardCursorNull, - _glfwDestroyCursorNull, - _glfwSetCursorNull, - _glfwGetScancodeNameNull, - _glfwGetKeyScancodeNull, - _glfwSetClipboardStringNull, - _glfwGetClipboardStringNull, - _glfwInitJoysticksNull, - _glfwTerminateJoysticksNull, - _glfwPollJoystickNull, - _glfwGetMappingNameNull, - _glfwUpdateGamepadGUIDNull, - _glfwFreeMonitorNull, - _glfwGetMonitorPosNull, - _glfwGetMonitorContentScaleNull, - _glfwGetMonitorWorkareaNull, - _glfwGetVideoModesNull, - _glfwGetVideoModeNull, - _glfwGetGammaRampNull, - _glfwSetGammaRampNull, - _glfwCreateWindowNull, - _glfwDestroyWindowNull, - _glfwSetWindowTitleNull, - _glfwSetWindowIconNull, - _glfwGetWindowPosNull, - _glfwSetWindowPosNull, - _glfwGetWindowSizeNull, - _glfwSetWindowSizeNull, - _glfwSetWindowSizeLimitsNull, - _glfwSetWindowAspectRatioNull, - _glfwGetFramebufferSizeNull, - _glfwGetWindowFrameSizeNull, - _glfwGetWindowContentScaleNull, - _glfwIconifyWindowNull, - _glfwRestoreWindowNull, - _glfwMaximizeWindowNull, - _glfwShowWindowNull, - _glfwHideWindowNull, - _glfwRequestWindowAttentionNull, - _glfwFocusWindowNull, - _glfwSetWindowMonitorNull, - _glfwWindowFocusedNull, - _glfwWindowIconifiedNull, - _glfwWindowVisibleNull, - _glfwWindowMaximizedNull, - _glfwWindowHoveredNull, - _glfwFramebufferTransparentNull, - _glfwGetWindowOpacityNull, - _glfwSetWindowResizableNull, - _glfwSetWindowDecoratedNull, - _glfwSetWindowFloatingNull, - _glfwSetWindowOpacityNull, - _glfwSetWindowMousePassthroughNull, - _glfwPollEventsNull, - _glfwWaitEventsNull, - _glfwWaitEventsTimeoutNull, - _glfwPostEmptyEventNull, - _glfwGetEGLPlatformNull, - _glfwGetEGLNativeDisplayNull, - _glfwGetEGLNativeWindowNull, - _glfwGetRequiredInstanceExtensionsNull, - _glfwGetPhysicalDevicePresentationSupportNull, - _glfwCreateWindowSurfaceNull, + .platformID = GLFW_PLATFORM_NULL, + .init = _glfwInitNull, + .terminate = _glfwTerminateNull, + .getCursorPos = _glfwGetCursorPosNull, + .setCursorPos = _glfwSetCursorPosNull, + .setCursorMode = _glfwSetCursorModeNull, + .setRawMouseMotion = _glfwSetRawMouseMotionNull, + .rawMouseMotionSupported = _glfwRawMouseMotionSupportedNull, + .createCursor = _glfwCreateCursorNull, + .createStandardCursor = _glfwCreateStandardCursorNull, + .destroyCursor = _glfwDestroyCursorNull, + .setCursor = _glfwSetCursorNull, + .getScancodeName = _glfwGetScancodeNameNull, + .getKeyScancode = _glfwGetKeyScancodeNull, + .setClipboardString = _glfwSetClipboardStringNull, + .getClipboardString = _glfwGetClipboardStringNull, + .initJoysticks = _glfwInitJoysticksNull, + .terminateJoysticks = _glfwTerminateJoysticksNull, + .pollJoystick = _glfwPollJoystickNull, + .getMappingName = _glfwGetMappingNameNull, + .updateGamepadGUID = _glfwUpdateGamepadGUIDNull, + .freeMonitor = _glfwFreeMonitorNull, + .getMonitorPos = _glfwGetMonitorPosNull, + .getMonitorContentScale = _glfwGetMonitorContentScaleNull, + .getMonitorWorkarea = _glfwGetMonitorWorkareaNull, + .getVideoModes = _glfwGetVideoModesNull, + .getVideoMode = _glfwGetVideoModeNull, + .getGammaRamp = _glfwGetGammaRampNull, + .setGammaRamp = _glfwSetGammaRampNull, + .createWindow = _glfwCreateWindowNull, + .destroyWindow = _glfwDestroyWindowNull, + .setWindowTitle = _glfwSetWindowTitleNull, + .setWindowIcon = _glfwSetWindowIconNull, + .getWindowPos = _glfwGetWindowPosNull, + .setWindowPos = _glfwSetWindowPosNull, + .getWindowSize = _glfwGetWindowSizeNull, + .setWindowSize = _glfwSetWindowSizeNull, + .setWindowSizeLimits = _glfwSetWindowSizeLimitsNull, + .setWindowAspectRatio = _glfwSetWindowAspectRatioNull, + .getFramebufferSize = _glfwGetFramebufferSizeNull, + .getWindowFrameSize = _glfwGetWindowFrameSizeNull, + .getWindowContentScale = _glfwGetWindowContentScaleNull, + .iconifyWindow = _glfwIconifyWindowNull, + .restoreWindow = _glfwRestoreWindowNull, + .maximizeWindow = _glfwMaximizeWindowNull, + .showWindow = _glfwShowWindowNull, + .hideWindow = _glfwHideWindowNull, + .requestWindowAttention = _glfwRequestWindowAttentionNull, + .focusWindow = _glfwFocusWindowNull, + .setWindowMonitor = _glfwSetWindowMonitorNull, + .windowFocused = _glfwWindowFocusedNull, + .windowIconified = _glfwWindowIconifiedNull, + .windowVisible = _glfwWindowVisibleNull, + .windowMaximized = _glfwWindowMaximizedNull, + .windowHovered = _glfwWindowHoveredNull, + .framebufferTransparent = _glfwFramebufferTransparentNull, + .getWindowOpacity = _glfwGetWindowOpacityNull, + .setWindowResizable = _glfwSetWindowResizableNull, + .setWindowDecorated = _glfwSetWindowDecoratedNull, + .setWindowFloating = _glfwSetWindowFloatingNull, + .setWindowOpacity = _glfwSetWindowOpacityNull, + .setWindowMousePassthrough = _glfwSetWindowMousePassthroughNull, + .pollEvents = _glfwPollEventsNull, + .waitEvents = _glfwWaitEventsNull, + .waitEventsTimeout = _glfwWaitEventsTimeoutNull, + .postEmptyEvent = _glfwPostEmptyEventNull, + .getEGLPlatform = _glfwGetEGLPlatformNull, + .getEGLNativeDisplay = _glfwGetEGLNativeDisplayNull, + .getEGLNativeWindow = _glfwGetEGLNativeWindowNull, + .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsNull, + .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportNull, + .createWindowSurface = _glfwCreateWindowSurfaceNull }; *platform = null; diff --git a/src/win32_init.c b/src/win32_init.c index 739c9c33..25fde325 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -642,78 +642,78 @@ GLFWbool _glfwConnectWin32(int platformID, _GLFWplatform* platform) { const _GLFWplatform win32 = { - GLFW_PLATFORM_WIN32, - _glfwInitWin32, - _glfwTerminateWin32, - _glfwGetCursorPosWin32, - _glfwSetCursorPosWin32, - _glfwSetCursorModeWin32, - _glfwSetRawMouseMotionWin32, - _glfwRawMouseMotionSupportedWin32, - _glfwCreateCursorWin32, - _glfwCreateStandardCursorWin32, - _glfwDestroyCursorWin32, - _glfwSetCursorWin32, - _glfwGetScancodeNameWin32, - _glfwGetKeyScancodeWin32, - _glfwSetClipboardStringWin32, - _glfwGetClipboardStringWin32, - _glfwInitJoysticksWin32, - _glfwTerminateJoysticksWin32, - _glfwPollJoystickWin32, - _glfwGetMappingNameWin32, - _glfwUpdateGamepadGUIDWin32, - _glfwFreeMonitorWin32, - _glfwGetMonitorPosWin32, - _glfwGetMonitorContentScaleWin32, - _glfwGetMonitorWorkareaWin32, - _glfwGetVideoModesWin32, - _glfwGetVideoModeWin32, - _glfwGetGammaRampWin32, - _glfwSetGammaRampWin32, - _glfwCreateWindowWin32, - _glfwDestroyWindowWin32, - _glfwSetWindowTitleWin32, - _glfwSetWindowIconWin32, - _glfwGetWindowPosWin32, - _glfwSetWindowPosWin32, - _glfwGetWindowSizeWin32, - _glfwSetWindowSizeWin32, - _glfwSetWindowSizeLimitsWin32, - _glfwSetWindowAspectRatioWin32, - _glfwGetFramebufferSizeWin32, - _glfwGetWindowFrameSizeWin32, - _glfwGetWindowContentScaleWin32, - _glfwIconifyWindowWin32, - _glfwRestoreWindowWin32, - _glfwMaximizeWindowWin32, - _glfwShowWindowWin32, - _glfwHideWindowWin32, - _glfwRequestWindowAttentionWin32, - _glfwFocusWindowWin32, - _glfwSetWindowMonitorWin32, - _glfwWindowFocusedWin32, - _glfwWindowIconifiedWin32, - _glfwWindowVisibleWin32, - _glfwWindowMaximizedWin32, - _glfwWindowHoveredWin32, - _glfwFramebufferTransparentWin32, - _glfwGetWindowOpacityWin32, - _glfwSetWindowResizableWin32, - _glfwSetWindowDecoratedWin32, - _glfwSetWindowFloatingWin32, - _glfwSetWindowOpacityWin32, - _glfwSetWindowMousePassthroughWin32, - _glfwPollEventsWin32, - _glfwWaitEventsWin32, - _glfwWaitEventsTimeoutWin32, - _glfwPostEmptyEventWin32, - _glfwGetEGLPlatformWin32, - _glfwGetEGLNativeDisplayWin32, - _glfwGetEGLNativeWindowWin32, - _glfwGetRequiredInstanceExtensionsWin32, - _glfwGetPhysicalDevicePresentationSupportWin32, - _glfwCreateWindowSurfaceWin32, + .platformID = GLFW_PLATFORM_WIN32, + .init = _glfwInitWin32, + .terminate = _glfwTerminateWin32, + .getCursorPos = _glfwGetCursorPosWin32, + .setCursorPos = _glfwSetCursorPosWin32, + .setCursorMode = _glfwSetCursorModeWin32, + .setRawMouseMotion = _glfwSetRawMouseMotionWin32, + .rawMouseMotionSupported = _glfwRawMouseMotionSupportedWin32, + .createCursor = _glfwCreateCursorWin32, + .createStandardCursor = _glfwCreateStandardCursorWin32, + .destroyCursor = _glfwDestroyCursorWin32, + .setCursor = _glfwSetCursorWin32, + .getScancodeName = _glfwGetScancodeNameWin32, + .getKeyScancode = _glfwGetKeyScancodeWin32, + .setClipboardString = _glfwSetClipboardStringWin32, + .getClipboardString = _glfwGetClipboardStringWin32, + .initJoysticks = _glfwInitJoysticksWin32, + .terminateJoysticks = _glfwTerminateJoysticksWin32, + .pollJoystick = _glfwPollJoystickWin32, + .getMappingName = _glfwGetMappingNameWin32, + .updateGamepadGUID = _glfwUpdateGamepadGUIDWin32, + .freeMonitor = _glfwFreeMonitorWin32, + .getMonitorPos = _glfwGetMonitorPosWin32, + .getMonitorContentScale = _glfwGetMonitorContentScaleWin32, + .getMonitorWorkarea = _glfwGetMonitorWorkareaWin32, + .getVideoModes = _glfwGetVideoModesWin32, + .getVideoMode = _glfwGetVideoModeWin32, + .getGammaRamp = _glfwGetGammaRampWin32, + .setGammaRamp = _glfwSetGammaRampWin32, + .createWindow = _glfwCreateWindowWin32, + .destroyWindow = _glfwDestroyWindowWin32, + .setWindowTitle = _glfwSetWindowTitleWin32, + .setWindowIcon = _glfwSetWindowIconWin32, + .getWindowPos = _glfwGetWindowPosWin32, + .setWindowPos = _glfwSetWindowPosWin32, + .getWindowSize = _glfwGetWindowSizeWin32, + .setWindowSize = _glfwSetWindowSizeWin32, + .setWindowSizeLimits = _glfwSetWindowSizeLimitsWin32, + .setWindowAspectRatio = _glfwSetWindowAspectRatioWin32, + .getFramebufferSize = _glfwGetFramebufferSizeWin32, + .getWindowFrameSize = _glfwGetWindowFrameSizeWin32, + .getWindowContentScale = _glfwGetWindowContentScaleWin32, + .iconifyWindow = _glfwIconifyWindowWin32, + .restoreWindow = _glfwRestoreWindowWin32, + .maximizeWindow = _glfwMaximizeWindowWin32, + .showWindow = _glfwShowWindowWin32, + .hideWindow = _glfwHideWindowWin32, + .requestWindowAttention = _glfwRequestWindowAttentionWin32, + .focusWindow = _glfwFocusWindowWin32, + .setWindowMonitor = _glfwSetWindowMonitorWin32, + .windowFocused = _glfwWindowFocusedWin32, + .windowIconified = _glfwWindowIconifiedWin32, + .windowVisible = _glfwWindowVisibleWin32, + .windowMaximized = _glfwWindowMaximizedWin32, + .windowHovered = _glfwWindowHoveredWin32, + .framebufferTransparent = _glfwFramebufferTransparentWin32, + .getWindowOpacity = _glfwGetWindowOpacityWin32, + .setWindowResizable = _glfwSetWindowResizableWin32, + .setWindowDecorated = _glfwSetWindowDecoratedWin32, + .setWindowFloating = _glfwSetWindowFloatingWin32, + .setWindowOpacity = _glfwSetWindowOpacityWin32, + .setWindowMousePassthrough = _glfwSetWindowMousePassthroughWin32, + .pollEvents = _glfwPollEventsWin32, + .waitEvents = _glfwWaitEventsWin32, + .waitEventsTimeout = _glfwWaitEventsTimeoutWin32, + .postEmptyEvent = _glfwPostEmptyEventWin32, + .getEGLPlatform = _glfwGetEGLPlatformWin32, + .getEGLNativeDisplay = _glfwGetEGLNativeDisplayWin32, + .getEGLNativeWindow = _glfwGetEGLNativeWindowWin32, + .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsWin32, + .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportWin32, + .createWindowSurface = _glfwCreateWindowSurfaceWin32 }; *platform = win32; diff --git a/src/wl_init.c b/src/wl_init.c index a4692b52..4b90642c 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -405,86 +405,86 @@ GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform) { const _GLFWplatform wayland = { - GLFW_PLATFORM_WAYLAND, - _glfwInitWayland, - _glfwTerminateWayland, - _glfwGetCursorPosWayland, - _glfwSetCursorPosWayland, - _glfwSetCursorModeWayland, - _glfwSetRawMouseMotionWayland, - _glfwRawMouseMotionSupportedWayland, - _glfwCreateCursorWayland, - _glfwCreateStandardCursorWayland, - _glfwDestroyCursorWayland, - _glfwSetCursorWayland, - _glfwGetScancodeNameWayland, - _glfwGetKeyScancodeWayland, - _glfwSetClipboardStringWayland, - _glfwGetClipboardStringWayland, + .platformID = GLFW_PLATFORM_WAYLAND, + .init = _glfwInitWayland, + .terminate = _glfwTerminateWayland, + .getCursorPos = _glfwGetCursorPosWayland, + .setCursorPos = _glfwSetCursorPosWayland, + .setCursorMode = _glfwSetCursorModeWayland, + .setRawMouseMotion = _glfwSetRawMouseMotionWayland, + .rawMouseMotionSupported = _glfwRawMouseMotionSupportedWayland, + .createCursor = _glfwCreateCursorWayland, + .createStandardCursor = _glfwCreateStandardCursorWayland, + .destroyCursor = _glfwDestroyCursorWayland, + .setCursor = _glfwSetCursorWayland, + .getScancodeName = _glfwGetScancodeNameWayland, + .getKeyScancode = _glfwGetKeyScancodeWayland, + .setClipboardString = _glfwSetClipboardStringWayland, + .getClipboardString = _glfwGetClipboardStringWayland, #if defined(GLFW_BUILD_LINUX_JOYSTICK) - _glfwInitJoysticksLinux, - _glfwTerminateJoysticksLinux, - _glfwPollJoystickLinux, - _glfwGetMappingNameLinux, - _glfwUpdateGamepadGUIDLinux, + .initJoysticks = _glfwInitJoysticksLinux, + .terminateJoysticks = _glfwTerminateJoysticksLinux, + .pollJoystick = _glfwPollJoystickLinux, + .getMappingName = _glfwGetMappingNameLinux, + .updateGamepadGUID = _glfwUpdateGamepadGUIDLinux, #else - _glfwInitJoysticksNull, - _glfwTerminateJoysticksNull, - _glfwPollJoystickNull, - _glfwGetMappingNameNull, - _glfwUpdateGamepadGUIDNull, + .initJoysticks = _glfwInitJoysticksNull, + .terminateJoysticks = _glfwTerminateJoysticksNull, + .pollJoystick = _glfwPollJoystickNull, + .getMappingName = _glfwGetMappingNameNull, + .updateGamepadGUID = _glfwUpdateGamepadGUIDNull, #endif - _glfwFreeMonitorWayland, - _glfwGetMonitorPosWayland, - _glfwGetMonitorContentScaleWayland, - _glfwGetMonitorWorkareaWayland, - _glfwGetVideoModesWayland, - _glfwGetVideoModeWayland, - _glfwGetGammaRampWayland, - _glfwSetGammaRampWayland, - _glfwCreateWindowWayland, - _glfwDestroyWindowWayland, - _glfwSetWindowTitleWayland, - _glfwSetWindowIconWayland, - _glfwGetWindowPosWayland, - _glfwSetWindowPosWayland, - _glfwGetWindowSizeWayland, - _glfwSetWindowSizeWayland, - _glfwSetWindowSizeLimitsWayland, - _glfwSetWindowAspectRatioWayland, - _glfwGetFramebufferSizeWayland, - _glfwGetWindowFrameSizeWayland, - _glfwGetWindowContentScaleWayland, - _glfwIconifyWindowWayland, - _glfwRestoreWindowWayland, - _glfwMaximizeWindowWayland, - _glfwShowWindowWayland, - _glfwHideWindowWayland, - _glfwRequestWindowAttentionWayland, - _glfwFocusWindowWayland, - _glfwSetWindowMonitorWayland, - _glfwWindowFocusedWayland, - _glfwWindowIconifiedWayland, - _glfwWindowVisibleWayland, - _glfwWindowMaximizedWayland, - _glfwWindowHoveredWayland, - _glfwFramebufferTransparentWayland, - _glfwGetWindowOpacityWayland, - _glfwSetWindowResizableWayland, - _glfwSetWindowDecoratedWayland, - _glfwSetWindowFloatingWayland, - _glfwSetWindowOpacityWayland, - _glfwSetWindowMousePassthroughWayland, - _glfwPollEventsWayland, - _glfwWaitEventsWayland, - _glfwWaitEventsTimeoutWayland, - _glfwPostEmptyEventWayland, - _glfwGetEGLPlatformWayland, - _glfwGetEGLNativeDisplayWayland, - _glfwGetEGLNativeWindowWayland, - _glfwGetRequiredInstanceExtensionsWayland, - _glfwGetPhysicalDevicePresentationSupportWayland, - _glfwCreateWindowSurfaceWayland, + .freeMonitor = _glfwFreeMonitorWayland, + .getMonitorPos = _glfwGetMonitorPosWayland, + .getMonitorContentScale = _glfwGetMonitorContentScaleWayland, + .getMonitorWorkarea = _glfwGetMonitorWorkareaWayland, + .getVideoModes = _glfwGetVideoModesWayland, + .getVideoMode = _glfwGetVideoModeWayland, + .getGammaRamp = _glfwGetGammaRampWayland, + .setGammaRamp = _glfwSetGammaRampWayland, + .createWindow = _glfwCreateWindowWayland, + .destroyWindow = _glfwDestroyWindowWayland, + .setWindowTitle = _glfwSetWindowTitleWayland, + .setWindowIcon = _glfwSetWindowIconWayland, + .getWindowPos = _glfwGetWindowPosWayland, + .setWindowPos = _glfwSetWindowPosWayland, + .getWindowSize = _glfwGetWindowSizeWayland, + .setWindowSize = _glfwSetWindowSizeWayland, + .setWindowSizeLimits = _glfwSetWindowSizeLimitsWayland, + .setWindowAspectRatio = _glfwSetWindowAspectRatioWayland, + .getFramebufferSize = _glfwGetFramebufferSizeWayland, + .getWindowFrameSize = _glfwGetWindowFrameSizeWayland, + .getWindowContentScale = _glfwGetWindowContentScaleWayland, + .iconifyWindow = _glfwIconifyWindowWayland, + .restoreWindow = _glfwRestoreWindowWayland, + .maximizeWindow = _glfwMaximizeWindowWayland, + .showWindow = _glfwShowWindowWayland, + .hideWindow = _glfwHideWindowWayland, + .requestWindowAttention = _glfwRequestWindowAttentionWayland, + .focusWindow = _glfwFocusWindowWayland, + .setWindowMonitor = _glfwSetWindowMonitorWayland, + .windowFocused = _glfwWindowFocusedWayland, + .windowIconified = _glfwWindowIconifiedWayland, + .windowVisible = _glfwWindowVisibleWayland, + .windowMaximized = _glfwWindowMaximizedWayland, + .windowHovered = _glfwWindowHoveredWayland, + .framebufferTransparent = _glfwFramebufferTransparentWayland, + .getWindowOpacity = _glfwGetWindowOpacityWayland, + .setWindowResizable = _glfwSetWindowResizableWayland, + .setWindowDecorated = _glfwSetWindowDecoratedWayland, + .setWindowFloating = _glfwSetWindowFloatingWayland, + .setWindowOpacity = _glfwSetWindowOpacityWayland, + .setWindowMousePassthrough = _glfwSetWindowMousePassthroughWayland, + .pollEvents = _glfwPollEventsWayland, + .waitEvents = _glfwWaitEventsWayland, + .waitEventsTimeout = _glfwWaitEventsTimeoutWayland, + .postEmptyEvent = _glfwPostEmptyEventWayland, + .getEGLPlatform = _glfwGetEGLPlatformWayland, + .getEGLNativeDisplay = _glfwGetEGLNativeDisplayWayland, + .getEGLNativeWindow = _glfwGetEGLNativeWindowWayland, + .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsWayland, + .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportWayland, + .createWindowSurface = _glfwCreateWindowSurfaceWayland }; void* module = _glfwPlatformLoadModule("libwayland-client.so.0"); diff --git a/src/x11_init.c b/src/x11_init.c index c90b593c..e992f444 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1166,86 +1166,86 @@ GLFWbool _glfwConnectX11(int platformID, _GLFWplatform* platform) { const _GLFWplatform x11 = { - GLFW_PLATFORM_X11, - _glfwInitX11, - _glfwTerminateX11, - _glfwGetCursorPosX11, - _glfwSetCursorPosX11, - _glfwSetCursorModeX11, - _glfwSetRawMouseMotionX11, - _glfwRawMouseMotionSupportedX11, - _glfwCreateCursorX11, - _glfwCreateStandardCursorX11, - _glfwDestroyCursorX11, - _glfwSetCursorX11, - _glfwGetScancodeNameX11, - _glfwGetKeyScancodeX11, - _glfwSetClipboardStringX11, - _glfwGetClipboardStringX11, + .platformID = GLFW_PLATFORM_X11, + .init = _glfwInitX11, + .terminate = _glfwTerminateX11, + .getCursorPos = _glfwGetCursorPosX11, + .setCursorPos = _glfwSetCursorPosX11, + .setCursorMode = _glfwSetCursorModeX11, + .setRawMouseMotion = _glfwSetRawMouseMotionX11, + .rawMouseMotionSupported = _glfwRawMouseMotionSupportedX11, + .createCursor = _glfwCreateCursorX11, + .createStandardCursor = _glfwCreateStandardCursorX11, + .destroyCursor = _glfwDestroyCursorX11, + .setCursor = _glfwSetCursorX11, + .getScancodeName = _glfwGetScancodeNameX11, + .getKeyScancode = _glfwGetKeyScancodeX11, + .setClipboardString = _glfwSetClipboardStringX11, + .getClipboardString = _glfwGetClipboardStringX11, #if defined(GLFW_BUILD_LINUX_JOYSTICK) - _glfwInitJoysticksLinux, - _glfwTerminateJoysticksLinux, - _glfwPollJoystickLinux, - _glfwGetMappingNameLinux, - _glfwUpdateGamepadGUIDLinux, + .initJoysticks = _glfwInitJoysticksLinux, + .terminateJoysticks = _glfwTerminateJoysticksLinux, + .pollJoystick = _glfwPollJoystickLinux, + .getMappingName = _glfwGetMappingNameLinux, + .updateGamepadGUID = _glfwUpdateGamepadGUIDLinux, #else - _glfwInitJoysticksNull, - _glfwTerminateJoysticksNull, - _glfwPollJoystickNull, - _glfwGetMappingNameNull, - _glfwUpdateGamepadGUIDNull, + .initJoysticks = _glfwInitJoysticksNull, + .terminateJoysticks = _glfwTerminateJoysticksNull, + .pollJoystick = _glfwPollJoystickNull, + .getMappingName = _glfwGetMappingNameNull, + .updateGamepadGUID = _glfwUpdateGamepadGUIDNull, #endif - _glfwFreeMonitorX11, - _glfwGetMonitorPosX11, - _glfwGetMonitorContentScaleX11, - _glfwGetMonitorWorkareaX11, - _glfwGetVideoModesX11, - _glfwGetVideoModeX11, - _glfwGetGammaRampX11, - _glfwSetGammaRampX11, - _glfwCreateWindowX11, - _glfwDestroyWindowX11, - _glfwSetWindowTitleX11, - _glfwSetWindowIconX11, - _glfwGetWindowPosX11, - _glfwSetWindowPosX11, - _glfwGetWindowSizeX11, - _glfwSetWindowSizeX11, - _glfwSetWindowSizeLimitsX11, - _glfwSetWindowAspectRatioX11, - _glfwGetFramebufferSizeX11, - _glfwGetWindowFrameSizeX11, - _glfwGetWindowContentScaleX11, - _glfwIconifyWindowX11, - _glfwRestoreWindowX11, - _glfwMaximizeWindowX11, - _glfwShowWindowX11, - _glfwHideWindowX11, - _glfwRequestWindowAttentionX11, - _glfwFocusWindowX11, - _glfwSetWindowMonitorX11, - _glfwWindowFocusedX11, - _glfwWindowIconifiedX11, - _glfwWindowVisibleX11, - _glfwWindowMaximizedX11, - _glfwWindowHoveredX11, - _glfwFramebufferTransparentX11, - _glfwGetWindowOpacityX11, - _glfwSetWindowResizableX11, - _glfwSetWindowDecoratedX11, - _glfwSetWindowFloatingX11, - _glfwSetWindowOpacityX11, - _glfwSetWindowMousePassthroughX11, - _glfwPollEventsX11, - _glfwWaitEventsX11, - _glfwWaitEventsTimeoutX11, - _glfwPostEmptyEventX11, - _glfwGetEGLPlatformX11, - _glfwGetEGLNativeDisplayX11, - _glfwGetEGLNativeWindowX11, - _glfwGetRequiredInstanceExtensionsX11, - _glfwGetPhysicalDevicePresentationSupportX11, - _glfwCreateWindowSurfaceX11, + .freeMonitor = _glfwFreeMonitorX11, + .getMonitorPos = _glfwGetMonitorPosX11, + .getMonitorContentScale = _glfwGetMonitorContentScaleX11, + .getMonitorWorkarea = _glfwGetMonitorWorkareaX11, + .getVideoModes = _glfwGetVideoModesX11, + .getVideoMode = _glfwGetVideoModeX11, + .getGammaRamp = _glfwGetGammaRampX11, + .setGammaRamp = _glfwSetGammaRampX11, + .createWindow = _glfwCreateWindowX11, + .destroyWindow = _glfwDestroyWindowX11, + .setWindowTitle = _glfwSetWindowTitleX11, + .setWindowIcon = _glfwSetWindowIconX11, + .getWindowPos = _glfwGetWindowPosX11, + .setWindowPos = _glfwSetWindowPosX11, + .getWindowSize = _glfwGetWindowSizeX11, + .setWindowSize = _glfwSetWindowSizeX11, + .setWindowSizeLimits = _glfwSetWindowSizeLimitsX11, + .setWindowAspectRatio = _glfwSetWindowAspectRatioX11, + .getFramebufferSize = _glfwGetFramebufferSizeX11, + .getWindowFrameSize = _glfwGetWindowFrameSizeX11, + .getWindowContentScale = _glfwGetWindowContentScaleX11, + .iconifyWindow = _glfwIconifyWindowX11, + .restoreWindow = _glfwRestoreWindowX11, + .maximizeWindow = _glfwMaximizeWindowX11, + .showWindow = _glfwShowWindowX11, + .hideWindow = _glfwHideWindowX11, + .requestWindowAttention = _glfwRequestWindowAttentionX11, + .focusWindow = _glfwFocusWindowX11, + .setWindowMonitor = _glfwSetWindowMonitorX11, + .windowFocused = _glfwWindowFocusedX11, + .windowIconified = _glfwWindowIconifiedX11, + .windowVisible = _glfwWindowVisibleX11, + .windowMaximized = _glfwWindowMaximizedX11, + .windowHovered = _glfwWindowHoveredX11, + .framebufferTransparent = _glfwFramebufferTransparentX11, + .getWindowOpacity = _glfwGetWindowOpacityX11, + .setWindowResizable = _glfwSetWindowResizableX11, + .setWindowDecorated = _glfwSetWindowDecoratedX11, + .setWindowFloating = _glfwSetWindowFloatingX11, + .setWindowOpacity = _glfwSetWindowOpacityX11, + .setWindowMousePassthrough = _glfwSetWindowMousePassthroughX11, + .pollEvents = _glfwPollEventsX11, + .waitEvents = _glfwWaitEventsX11, + .waitEventsTimeout = _glfwWaitEventsTimeoutX11, + .postEmptyEvent = _glfwPostEmptyEventX11, + .getEGLPlatform = _glfwGetEGLPlatformX11, + .getEGLNativeDisplay = _glfwGetEGLNativeDisplayX11, + .getEGLNativeWindow = _glfwGetEGLNativeWindowX11, + .getRequiredInstanceExtensions = _glfwGetRequiredInstanceExtensionsX11, + .getPhysicalDevicePresentationSupport = _glfwGetPhysicalDevicePresentationSupportX11, + .createWindowSurface = _glfwCreateWindowSurfaceX11 }; // HACK: If the application has left the locale as "C" then both wide From 86bf5698ecfdbe783135ffaf72972a8c562c0fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 13 Dec 2023 15:27:30 +0100 Subject: [PATCH 031/137] Fix glfwGetKeyName incorrectly emitting error glfwGetKeyName emitted GLFW_INVALID_VALUE when passed GLFW_KEY_UNKNOWN and any scancode not associated with a key token on that platform. This causes physical keys with no associated key token to emit GLFW_INVALID_VALUE when the key and scancode are passed directly from the key event to glfwGetKeyName. This breaks the promise made in the reference documentation for glfwGetKeyName. This commit removes that error for the whole range of valid scancodes. Fixes #1785 --- src/cocoa_window.m | 5 +++-- src/win32_window.c | 9 ++++++--- src/wl_window.c | 6 ++++-- src/x11_window.c | 6 ++++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 9d794940..c865c09e 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1659,14 +1659,15 @@ const char* _glfwGetScancodeNameCocoa(int scancode) { @autoreleasepool { - if (scancode < 0 || scancode > 0xff || - _glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN) + if (scancode < 0 || scancode > 0xff) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); return NULL; } const int key = _glfw.ns.keycodes[scancode]; + if (key == GLFW_KEY_UNKNOWN) + return NULL; UInt32 deadKeyState = 0; UniChar characters[4]; diff --git a/src/win32_window.c b/src/win32_window.c index db3bed6e..917a0f6c 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2223,14 +2223,17 @@ void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode) const char* _glfwGetScancodeNameWin32(int scancode) { - if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) || - _glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN) + if (scancode < 0 || scancode > (KF_EXTENDED | 0xff)) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); return NULL; } - return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]]; + const int key = _glfw.win32.keycodes[scancode]; + if (key == GLFW_KEY_UNKNOWN) + return NULL; + + return _glfw.win32.keynames[key]; } int _glfwGetKeyScancodeWin32(int key) diff --git a/src/wl_window.c b/src/wl_window.c index 8d8f8ab1..f047f44c 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2535,8 +2535,7 @@ void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode) const char* _glfwGetScancodeNameWayland(int scancode) { - if (scancode < 0 || scancode > 255 || - _glfw.wl.keycodes[scancode] == GLFW_KEY_UNKNOWN) + if (scancode < 0 || scancode > 255) { _glfwInputError(GLFW_INVALID_VALUE, "Wayland: Invalid scancode %i", @@ -2545,6 +2544,9 @@ const char* _glfwGetScancodeNameWayland(int scancode) } const int key = _glfw.wl.keycodes[scancode]; + if (key == GLFW_KEY_UNKNOWN) + return NULL; + const xkb_keycode_t keycode = scancode + 8; const xkb_layout_index_t layout = xkb_state_key_get_layout(_glfw.wl.xkb.state, keycode); diff --git a/src/x11_window.c b/src/x11_window.c index 3c76d3a9..c2541b9f 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2901,14 +2901,16 @@ const char* _glfwGetScancodeNameX11(int scancode) if (!_glfw.x11.xkb.available) return NULL; - if (scancode < 0 || scancode > 0xff || - _glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN) + if (scancode < 0 || scancode > 0xff) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); return NULL; } const int key = _glfw.x11.keycodes[scancode]; + if (key == GLFW_KEY_UNKNOWN) + return NULL; + const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0); if (keysym == NoSymbol) From becf1dc14b246f2994b60bbdd99ece60d6f86183 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sat, 16 Dec 2023 10:24:48 +0700 Subject: [PATCH 032/137] Update to actions/checkout@v4 from v3 This mainly updates the version of NodeJS used internally to keep up with what's going on at GitHub Actions. Closes #2447 --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 730e82b4..e980c547 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: CC: clang CFLAGS: -Werror steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: | sudo apt update @@ -57,7 +57,7 @@ jobs: MACOSX_DEPLOYMENT_TARGET: 10.8 CMAKE_OSX_ARCHITECTURES: x86_64;arm64 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Configure Null shared library run: cmake -B build-null-shared -D GLFW_BUILD_COCOA=OFF -D BUILD_SHARED_LIBS=ON @@ -81,7 +81,7 @@ jobs: env: CFLAGS: /WX steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Configure Win32 shared x86 library run: cmake -B build-win32-shared-x86 -G "Visual Studio 17 2022" -A Win32 -D BUILD_SHARED_LIBS=ON From bc95384f4cb9766d691e97ffe0ed7e090dd75fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 24 Jan 2024 13:55:37 +0100 Subject: [PATCH 033/137] Remove platform-specific logic from shared header The public header already defines APIENTRY, which is functionally identical to EGLAPIENTRY. --- src/internal.h | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/internal.h b/src/internal.h index fe0369aa..1ab3dea8 100644 --- a/src/internal.h +++ b/src/internal.h @@ -108,12 +108,6 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum); typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*); typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); -#if defined(_GLFW_WIN32) - #define EGLAPIENTRY __stdcall -#else - #define EGLAPIENTRY -#endif - #define EGL_SUCCESS 0x3000 #define EGL_NOT_INITIALIZED 0x3001 #define EGL_BAD_ACCESS 0x3002 @@ -200,22 +194,22 @@ typedef void* EGLNativeDisplayType; typedef void* EGLNativeWindowType; // EGL function pointer typedefs -typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); -typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType); -typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum); -typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); -typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); -typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); -typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); -typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); +typedef EGLBoolean (APIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); +typedef EGLBoolean (APIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); +typedef EGLDisplay (APIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType); +typedef EGLint (APIENTRY * PFN_eglGetError)(void); +typedef EGLBoolean (APIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*); +typedef EGLBoolean (APIENTRY * PFN_eglTerminate)(EGLDisplay); +typedef EGLBoolean (APIENTRY * PFN_eglBindAPI)(EGLenum); +typedef EGLContext (APIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*); +typedef EGLBoolean (APIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); +typedef EGLBoolean (APIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); +typedef EGLSurface (APIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); +typedef EGLBoolean (APIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); +typedef EGLBoolean (APIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); +typedef EGLBoolean (APIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); +typedef const char* (APIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); +typedef GLFWglproc (APIENTRY * PFN_eglGetProcAddress)(const char*); #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib #define eglGetConfigs _glfw.egl.GetConfigs #define eglGetDisplay _glfw.egl.GetDisplay @@ -233,8 +227,8 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); #define eglQueryString _glfw.egl.QueryString #define eglGetProcAddress _glfw.egl.GetProcAddress -typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); -typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*); +typedef EGLDisplay (APIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); +typedef EGLSurface (APIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*); #define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT #define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT From 291f4d89cd3019b5d0be4fd5d97699036d1b0a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 24 Jan 2024 15:32:32 +0100 Subject: [PATCH 034/137] OSMesa: Fix headers included before shared header The shared header, internal.h, must be the first header included in every compilation unit of GLFW. --- src/osmesa_context.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/osmesa_context.c b/src/osmesa_context.c index a3f1a884..2f12adf2 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -25,13 +25,12 @@ // //======================================================================== +#include "internal.h" + #include #include #include -#include "internal.h" - - static void makeContextCurrentOSMesa(_GLFWwindow* window) { if (window) From 51920ede6827962ca2fbcad38d1beed1165400af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 24 Jan 2024 16:54:52 +0100 Subject: [PATCH 035/137] Wayland: Fix compilation on FreeBSD The list of compile-time dependencies on FreeBSD lacked evdev-proto. Unlike on Linux, the input-event-codes.h header file was not implicitly included on FreeBSD. Fixes #2445 --- docs/compile.dox | 8 ++++---- src/wl_window.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/compile.dox b/docs/compile.dox index ecf199a5..282076eb 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -101,12 +101,12 @@ On Fedora and derivatives like Red Hat you will need the `wayland-devel`, sudo dnf install wayland-devel libxkbcommon-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel @endcode -On FreeBSD you will need the `wayland` and `libxkbcommon` packages. The X11 headers are -installed along the end-user X11 packages, so if you have an X server running you should -have the headers as well. If not, install the `xorgproto` package. +On FreeBSD you will need the `wayland`, `libxkbcommon` and `evdev-proto` packages. The +X11 headers are installed along the end-user X11 packages, so if you have an X server +running you should have the headers as well. If not, install the `xorgproto` package. @code{.sh} -pkg install wayland libxkbcommon xorgproto +pkg install wayland libxkbcommon evdev-proto xorgproto @endcode Once you have the required dependencies, move on to @ref compile_generate. diff --git a/src/wl_window.c b/src/wl_window.c index f047f44c..73ebac4f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "wayland-client-protocol.h" #include "xdg-shell-client-protocol.h" From 2590d4cdd460b6d4a4bbc17328f283f447f1c3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 24 Jan 2024 20:52:24 +0100 Subject: [PATCH 036/137] Wayland: Enable platform by default This changes the default platform for Unix-like systems (other than macOS) from only X11 to Wayland and X11. It also removes the backward compatibility with the older GLFW_USE_WAYLAND CMake option. If a bisect took you here because your build broke, hello, sorry, set the GLFW_BUILD_WAYLAND or GLFW_BUILD_X11 CMake option to disable the associated platform. This can be done when configuring GLFW with CMake, from a higher-level CMakeLists.txt if GLFW is part of your project, or at any point after configuration by updating the CMake cache with the command-line tool or the GUI. The next step is to make Wayland the run-time default when enabled, but that will hopefully not break any builds. Related to #2439 --- CMakeLists.txt | 8 +++-- docs/compile.dox | 86 +++++++++++++++++------------------------------- 2 files changed, 37 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b51ae96..2e43fe21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,11 +27,15 @@ if (GLFW_USE_OSMESA) message(FATAL_ERROR "GLFW_USE_OSMESA has been removed; set the GLFW_PLATFORM init hint") endif() +if (DEFINED GLFW_USE_WAYLAND AND UNIX AND NOT APPLE) + message(FATAL_ERROR + "GLFW_USE_WAYLAND has been removed; set the GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 options") +endif() + cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF) cmake_dependent_option(GLFW_BUILD_COCOA "Build support for Cocoa" ON "APPLE" OFF) cmake_dependent_option(GLFW_BUILD_X11 "Build support for X11" ON "UNIX;NOT APPLE" OFF) -cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland" - "${GLFW_USE_WAYLAND}" "UNIX;NOT APPLE" OFF) +cmake_dependent_option(GLFW_BUILD_WAYLAND "Build support for Wayland" ON "UNIX;NOT APPLE" OFF) cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF "WIN32" OFF) diff --git a/docs/compile.dox b/docs/compile.dox index 282076eb..0c33ff0f 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -42,73 +42,48 @@ all necessary dependencies for compiling GLFW, but on Unix-like systems like Linux and FreeBSD you will need a few extra packages. -@subsubsection compile_deps_x11 Dependencies for X11 - -To compile GLFW for X11, you need to have the X11 development packages -installed. They are not needed to build or run programs that use GLFW. - -On Debian and derivatives like Ubuntu and Linux Mint the `xorg-dev` meta-package -pulls in the development packages for all of X11. - -@code{.sh} -sudo apt install xorg-dev -@endcode - -On Fedora and derivatives like Red Hat the X11 extension packages -`libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and `libXrandr-devel` -required by GLFW pull in all its other dependencies. - -@code{.sh} -sudo dnf install libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel -@endcode - -On FreeBSD the X11 headers are installed along the end-user X11 packages, so if -you have an X server running you should have the headers as well. If not, -install the `xorgproto` package. - -@code{.sh} -pkg install xorgproto -@endcode - -On Cygwin the `libXcursor-devel`, `libXi-devel`, `libXinerama-devel`, -`libXrandr-devel` and `libXrender-devel` packages in the Libs section of the GUI -installer will install all the headers and other development related files GLFW -requires for X11. - -Once you have the required dependencies, move on to @ref compile_generate. - - @subsubsection compile_deps_wayland Dependencies for Wayland and X11 +By default, both the Wayland and X11 backends are enabled on Linux and other Unix-like +systems (except macOS). To disable one or both of these, set the @ref GLFW_BUILD_WAYLAND +or @ref GLFW_BUILD_X11 CMake options in the next step when generating build files. + To compile GLFW for both Wayland and X11, you need to have the X11, Wayland and xkbcommon -development packages installed. They are not needed to build or run programs that use -GLFW. You will also need to set the @ref GLFW_BUILD_WAYLAND CMake option in the next -step when generating build files. +development packages installed. On some systems a few other packages are also required. +None of the development packages above are needed to build or run programs that use an +already compiled GLFW library. On Debian and derivatives like Ubuntu and Linux Mint you will need the `libwayland-dev` -and `libxkbcommon-dev` packages and the `xorg-dev` meta-package. These will pull in all -other dependencies. +and `libxkbcommon-dev` packages to compile for Wayland and the `xorg-dev` meta-package to +compile for X11. These will pull in all other dependencies. @code{.sh} sudo apt install libwayland-dev libxkbcommon-dev xorg-dev @endcode -On Fedora and derivatives like Red Hat you will need the `wayland-devel`, -`libxkbcommon-devel`, `libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and -`libXrandr-devel` packages. These will pull in all other dependencies. +On Fedora and derivatives like Red Hat you will need the `wayland-devel` and +`libxkbcommon-devel` packages to compile for Wayland and the `libXcursor-devel`, +`libXi-devel`, `libXinerama-devel` and `libXrandr-devel` packages to compile for X11. +These will pull in all other dependencies. @code{.sh} sudo dnf install wayland-devel libxkbcommon-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel @endcode -On FreeBSD you will need the `wayland`, `libxkbcommon` and `evdev-proto` packages. The -X11 headers are installed along the end-user X11 packages, so if you have an X server -running you should have the headers as well. If not, install the `xorgproto` package. +On FreeBSD you will need the `wayland`, `libxkbcommon` and `evdev-proto` packages to +compile for Wayland. The X11 headers are installed along the end-user X11 packages, so if +you have an X server running you should have the headers as well. If not, install the +`xorgproto` package to compile for X11. @code{.sh} pkg install wayland libxkbcommon evdev-proto xorgproto @endcode +On Cygwin Wayland is not supported but you will need the `libXcursor-devel`, +`libXi-devel`, `libXinerama-devel`, `libXrandr-devel` and `libXrender-devel` packages to +compile for X11. These can be found in the Libs section of the GUI installer and will +pull in all other dependencies. + Once you have the required dependencies, move on to @ref compile_generate. @@ -143,9 +118,10 @@ If you wish change any CMake variables in the list, press _Configure_ and then _Generate_ to have the new values take effect. The variable list will be populated after the first configure step. -By default, GLFW will use X11 on Linux and other Unix-like systems other than macOS. To -include support for Wayland as well, set the @ref GLFW_BUILD_WAYLAND option in the GLFW -section of the variable list, then apply the new value as described above. +By default, GLFW will use Wayland and X11 on Linux and other Unix-like systems other than +macOS. To disable support for one or both of these, set the @ref GLFW_BUILD_WAYLAND +and/or @ref GLFW_BUILD_X11 option in the GLFW section of the variable list, then apply the +new value as described above. Once you have generated the project files or makefiles for your chosen development environment, move on to @ref compile_compile. @@ -177,12 +153,12 @@ flag. cmake -S path/to/glfw -B path/to/build -G Xcode @endcode -By default, GLFW will use X11 on Linux and other Unix-like systems other -than macOS. To also include support for Wayland, set the @ref GLFW_BUILD_WAYLAND CMake -option. +By default, GLFW will use Wayland and X11 on Linux and other Unix-like systems other than +macOS. To disable support for one or both of these, set the @ref GLFW_BUILD_WAYLAND +and/or @ref GLFW_BUILD_X11 CMake option. @code{.sh} -cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_WAYLAND=1 +cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_X11=0 @endcode Once you have generated the project files or makefiles for your chosen @@ -315,7 +291,7 @@ default. @anchor GLFW_BUILD_WAYLAND __GLFW_BUILD_WAYLAND__ determines whether to include support for Wayland when compiling the library. This option is only available when compiling for Linux and other Unix-like -systems other than macOS. This is disabled by default. +systems other than macOS. This is enabled by default. @anchor GLFW_BUILD_X11 __GLFW_BUILD_X11__ determines whether to include support for X11 when compiling the From 93179702436b060aee0c2e28e5a681d72bf0d9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=BCrkamp?= Date: Wed, 24 Jan 2024 21:34:47 +0100 Subject: [PATCH 037/137] Wayland: Implement glfwRequestWindowAttention This implements window attention requests via the xdg-activation-v1 protocol. This was updated by @ elmindreda to work with recent Wayland related changes to the main branch: - Switched to current way of handling Wayland protocol files - Added the xdg-activation-v1.xml protocol file to deps/wayland - Added missing macros to rename protocol interface globals The protocol file was copied from wayland-protocols 1.33. Closes #2287 --- CONTRIBUTORS.md | 1 + README.md | 1 + deps/wayland/xdg-activation-v1.xml | 200 +++++++++++++++++++++++++++++ docs/compat.dox | 6 + src/CMakeLists.txt | 1 + src/wl_init.c | 14 ++ src/wl_platform.h | 4 + src/wl_window.c | 37 +++++- 8 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 deps/wayland/xdg-activation-v1.xml diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0bfa620d..570b7707 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -217,6 +217,7 @@ video tutorials. - Brandon Schaefer - Sebastian Schuberth - Scr3amer + - Jan Schuerkamp - Christian Sdunek - Matt Sealey - Steve Sexton diff --git a/README.md b/README.md index fd759897..23ba596d 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ information on what to include when reporting a bug. - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread would abort (#1649) + - [Wayland] Added support for `glfwRequestWindowAttention` (#2287) - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [X11] Bugfix: Termination would segfault if the IM had been destroyed diff --git a/deps/wayland/xdg-activation-v1.xml b/deps/wayland/xdg-activation-v1.xml new file mode 100644 index 00000000..9adcc274 --- /dev/null +++ b/deps/wayland/xdg-activation-v1.xml @@ -0,0 +1,200 @@ + + + + + Copyright © 2020 Aleix Pol Gonzalez <aleixpol@kde.org> + Copyright © 2020 Carlos Garnacho <carlosg@gnome.org> + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + The way for a client to pass focus to another toplevel is as follows. + + The client that intends to activate another toplevel uses the + xdg_activation_v1.get_activation_token request to get an activation token. + This token is then forwarded to the client, which is supposed to activate + one of its surfaces, through a separate band of communication. + + One established way of doing this is through the XDG_ACTIVATION_TOKEN + environment variable of a newly launched child process. The child process + should unset the environment variable again right after reading it out in + order to avoid propagating it to other child processes. + + Another established way exists for Applications implementing the D-Bus + interface org.freedesktop.Application, which should get their token under + activation-token on their platform_data. + + In general activation tokens may be transferred across clients through + means not described in this protocol. + + The client to be activated will then pass the token + it received to the xdg_activation_v1.activate request. The compositor can + then use this token to decide how to react to the activation request. + + The token the activating client gets may be ineffective either already at + the time it receives it, for example if it was not focused, for focus + stealing prevention. The activating client will have no way to discover + the validity of the token, and may still forward it to the to be activated + client. + + The created activation token may optionally get information attached to it + that can be used by the compositor to identify the application that we + intend to activate. This can for example be used to display a visual hint + about what application is being started. + + Warning! The protocol described in this file is currently in the testing + phase. Backward compatible changes may be added together with the + corresponding interface version bump. Backward incompatible changes can + only be done by creating a new major version of the extension. + + + + + A global interface used for informing the compositor about applications + being activated or started, or for applications to request to be + activated. + + + + + Notify the compositor that the xdg_activation object will no longer be + used. + + The child objects created via this interface are unaffected and should + be destroyed separately. + + + + + + Creates an xdg_activation_token_v1 object that will provide + the initiating client with a unique token for this activation. This + token should be offered to the clients to be activated. + + + + + + + + Requests surface activation. It's up to the compositor to display + this information as desired, for example by placing the surface above + the rest. + + The compositor may know who requested this by checking the activation + token and might decide not to follow through with the activation if it's + considered unwanted. + + Compositors can ignore unknown activation tokens when an invalid + token is passed. + + + + + + + + + An object for setting up a token and receiving a token handle that can + be passed as an activation token to another client. + + The object is created using the xdg_activation_v1.get_activation_token + request. This object should then be populated with the app_id, surface + and serial information and committed. The compositor shall then issue a + done event with the token. In case the request's parameters are invalid, + the compositor will provide an invalid token. + + + + + + + + + Provides information about the seat and serial event that requested the + token. + + The serial can come from an input or focus event. For instance, if a + click triggers the launch of a third-party client, the launcher client + should send a set_serial request with the serial and seat from the + wl_pointer.button event. + + Some compositors might refuse to activate toplevels when the token + doesn't have a valid and recent enough event serial. + + Must be sent before commit. This information is optional. + + + + + + + + The requesting client can specify an app_id to associate the token + being created with it. + + Must be sent before commit. This information is optional. + + + + + + + This request sets the surface requesting the activation. Note, this is + different from the surface that will be activated. + + Some compositors might refuse to activate toplevels when the token + doesn't have a requesting surface. + + Must be sent before commit. This information is optional. + + + + + + + Requests an activation token based on the different parameters that + have been offered through set_serial, set_surface and set_app_id. + + + + + + The 'done' event contains the unique token of this activation request + and notifies that the provider is done. + + + + + + + Notify the compositor that the xdg_activation_token_v1 object will no + longer be used. The received token stays valid. + + + + diff --git a/docs/compat.dox b/docs/compat.dox index 49b52bf4..bcd110c9 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -140,6 +140,12 @@ GLFW itself, using the alongside subsurfaces. If the running compositor does not support these protocols either, no decorations will be drawn around windows. +GLFW uses the [xdg-activation +protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/staging/xdg-activation/xdg-activation-v1.xml) +to enable attention requests. This protocol is part of +wayland-protocols staging, and mandatory at build time. If the running compositor +does not support this protocol, the attention requests do nothing. + @section compat_glx GLX extensions diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c49b31c9..45941647 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,6 +101,7 @@ if (GLFW_BUILD_WAYLAND) generate_wayland_protocol("idle-inhibit-unstable-v1.xml") generate_wayland_protocol("pointer-constraints-unstable-v1.xml") generate_wayland_protocol("relative-pointer-unstable-v1.xml") + generate_wayland_protocol("xdg-activation-v1.xml") generate_wayland_protocol("xdg-decoration-unstable-v1.xml") endif() diff --git a/src/wl_init.c b/src/wl_init.c index 4b90642c..b0e4e45e 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -46,6 +46,7 @@ #include "viewporter-client-protocol.h" #include "relative-pointer-unstable-v1-client-protocol.h" #include "pointer-constraints-unstable-v1-client-protocol.h" +#include "xdg-activation-v1-client-protocol.h" #include "idle-inhibit-unstable-v1-client-protocol.h" // NOTE: Versions of wayland-scanner prior to 1.17.91 named every global array of @@ -77,6 +78,10 @@ #include "pointer-constraints-unstable-v1-client-protocol-code.h" #undef types +#define types _glfw_xdg_activation_types +#include "xdg-activation-v1-client-protocol-code.h" +#undef types + #define types _glfw_idle_inhibit_types #include "idle-inhibit-unstable-v1-client-protocol-code.h" #undef types @@ -177,6 +182,13 @@ static void registryHandleGlobal(void* userData, &zwp_idle_inhibit_manager_v1_interface, 1); } + else if (strcmp(interface, "xdg_activation_v1") == 0) + { + _glfw.wl.activationManager = + wl_registry_bind(registry, name, + &xdg_activation_v1_interface, + 1); + } } static void registryHandleGlobalRemove(void* userData, @@ -929,6 +941,8 @@ void _glfwTerminateWayland(void) zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints); if (_glfw.wl.idleInhibitManager) zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager); + if (_glfw.wl.activationManager) + xdg_activation_v1_destroy(_glfw.wl.activationManager); if (_glfw.wl.registry) wl_registry_destroy(_glfw.wl.registry); if (_glfw.wl.display) diff --git a/src/wl_platform.h b/src/wl_platform.h index d00e28fe..7e8202e9 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -129,6 +129,8 @@ struct wl_output; #define xdg_surface_interface _glfw_xdg_surface_interface #define xdg_toplevel_interface _glfw_xdg_toplevel_interface #define xdg_wm_base_interface _glfw_xdg_wm_base_interface +#define xdg_activation_v1_interface _glfw_xdg_activation_v1_interface +#define xdg_activation_token_v1_interface _glfw_xdg_activation_token_v1_interface #define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl; #define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl; @@ -406,6 +408,7 @@ typedef struct _GLFWwindowWayland struct zwp_confined_pointer_v1* confinedPointer; struct zwp_idle_inhibitor_v1* idleInhibitor; + struct xdg_activation_token_v1* activationToken; struct { struct wl_buffer* buffer; @@ -434,6 +437,7 @@ typedef struct _GLFWlibraryWayland struct zwp_relative_pointer_manager_v1* relativePointerManager; struct zwp_pointer_constraints_v1* pointerConstraints; struct zwp_idle_inhibit_manager_v1* idleInhibitManager; + struct xdg_activation_v1* activationManager; _GLFWofferWayland* offers; unsigned int offerCount; diff --git a/src/wl_window.c b/src/wl_window.c index 73ebac4f..53c8c70a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -48,6 +48,7 @@ #include "viewporter-client-protocol.h" #include "relative-pointer-unstable-v1-client-protocol.h" #include "pointer-constraints-unstable-v1-client-protocol.h" +#include "xdg-activation-v1-client-protocol.h" #include "idle-inhibit-unstable-v1-client-protocol.h" #define GLFW_BORDER_SIZE 4 @@ -2054,6 +2055,9 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) if (window == _glfw.wl.keyboardFocus) _glfw.wl.keyboardFocus = NULL; + if (window->wl.activationToken) + xdg_activation_token_v1_destroy(window->wl.activationToken); + if (window->wl.idleInhibitor) zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor); @@ -2335,11 +2339,38 @@ void _glfwHideWindowWayland(_GLFWwindow* window) } } +static void xdgActivationHandleDone(void* userData, + struct xdg_activation_token_v1* activationToken, + const char* token) +{ + _GLFWwindow* window = userData; + + if(activationToken != window->wl.activationToken) + return; + + xdg_activation_v1_activate(_glfw.wl.activationManager, token, window->wl.surface); + xdg_activation_token_v1_destroy(window->wl.activationToken); + window->wl.activationToken = NULL; +} + +static const struct xdg_activation_token_v1_listener xdgActivationListener = +{ + xdgActivationHandleDone +}; + void _glfwRequestWindowAttentionWayland(_GLFWwindow* window) { - // TODO - _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, - "Wayland: Window attention request not implemented yet"); + if(!_glfw.wl.activationManager) + return; + + //We're about to overwrite this with a new request + if(window->wl.activationToken) + xdg_activation_token_v1_destroy(window->wl.activationToken); + + window->wl.activationToken = xdg_activation_v1_get_activation_token(_glfw.wl.activationManager); + xdg_activation_token_v1_add_listener(window->wl.activationToken, &xdgActivationListener, window); + + xdg_activation_token_v1_commit(window->wl.activationToken); } void _glfwFocusWindowWayland(_GLFWwindow* window) From bdedec9932f22e66b7c69461bd90b92785dcb9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 24 Jan 2024 23:51:36 +0100 Subject: [PATCH 038/137] Wayland: Fix formatting of attention request --- src/wl_window.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 53c8c70a..c7bada57 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2345,7 +2345,7 @@ static void xdgActivationHandleDone(void* userData, { _GLFWwindow* window = userData; - if(activationToken != window->wl.activationToken) + if (activationToken != window->wl.activationToken) return; xdg_activation_v1_activate(_glfw.wl.activationManager, token, window->wl.surface); @@ -2360,15 +2360,18 @@ static const struct xdg_activation_token_v1_listener xdgActivationListener = void _glfwRequestWindowAttentionWayland(_GLFWwindow* window) { - if(!_glfw.wl.activationManager) + if (!_glfw.wl.activationManager) return; - //We're about to overwrite this with a new request - if(window->wl.activationToken) + // We're about to overwrite this with a new request + if (window->wl.activationToken) xdg_activation_token_v1_destroy(window->wl.activationToken); - window->wl.activationToken = xdg_activation_v1_get_activation_token(_glfw.wl.activationManager); - xdg_activation_token_v1_add_listener(window->wl.activationToken, &xdgActivationListener, window); + window->wl.activationToken = + xdg_activation_v1_get_activation_token(_glfw.wl.activationManager); + xdg_activation_token_v1_add_listener(window->wl.activationToken, + &xdgActivationListener, + window); xdg_activation_token_v1_commit(window->wl.activationToken); } From 94310c52813e87925171a07391928b7a3d16f038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 25 Jan 2024 01:11:30 +0100 Subject: [PATCH 039/137] Wayland: Move listener to correct section --- src/wl_window.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index c7bada57..981f2401 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1980,6 +1980,25 @@ const struct wl_data_device_listener dataDeviceListener = dataDeviceHandleSelection, }; +static void xdgActivationHandleDone(void* userData, + struct xdg_activation_token_v1* activationToken, + const char* token) +{ + _GLFWwindow* window = userData; + + if (activationToken != window->wl.activationToken) + return; + + xdg_activation_v1_activate(_glfw.wl.activationManager, token, window->wl.surface); + xdg_activation_token_v1_destroy(window->wl.activationToken); + window->wl.activationToken = NULL; +} + +static const struct xdg_activation_token_v1_listener xdgActivationListener = +{ + xdgActivationHandleDone +}; + void _glfwAddSeatListenerWayland(struct wl_seat* seat) { wl_seat_add_listener(seat, &seatListener, NULL); @@ -2339,25 +2358,6 @@ void _glfwHideWindowWayland(_GLFWwindow* window) } } -static void xdgActivationHandleDone(void* userData, - struct xdg_activation_token_v1* activationToken, - const char* token) -{ - _GLFWwindow* window = userData; - - if (activationToken != window->wl.activationToken) - return; - - xdg_activation_v1_activate(_glfw.wl.activationManager, token, window->wl.surface); - xdg_activation_token_v1_destroy(window->wl.activationToken); - window->wl.activationToken = NULL; -} - -static const struct xdg_activation_token_v1_listener xdgActivationListener = -{ - xdgActivationHandleDone -}; - void _glfwRequestWindowAttentionWayland(_GLFWwindow* window) { if (!_glfw.wl.activationManager) From ad264f5061533e3dfed502a2bd16eb1839880478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 25 Jan 2024 12:39:34 +0100 Subject: [PATCH 040/137] Update URL for xdg-activation-v1 protocol docs --- docs/compat.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/compat.dox b/docs/compat.dox index bcd110c9..ddcd4dbc 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -141,7 +141,7 @@ alongside subsurfaces. If the running compositor does not support these protocols either, no decorations will be drawn around windows. GLFW uses the [xdg-activation -protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/staging/xdg-activation/xdg-activation-v1.xml) +protocol](https://wayland.app/protocols/xdg-activation-v1) to enable attention requests. This protocol is part of wayland-protocols staging, and mandatory at build time. If the running compositor does not support this protocol, the attention requests do nothing. From 23962c9dc7e0aa59199211b03a6fbb5700c01c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 25 Jan 2024 16:30:56 +0100 Subject: [PATCH 041/137] Remove further traces of IRC channel --- README.md | 5 ++--- docs/CONTRIBUTING.md | 7 +++---- docs/SUPPORT.md | 3 +-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 23ba596d..5bba59c7 100644 --- a/README.md +++ b/README.md @@ -431,13 +431,12 @@ On [glfw.org](https://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](https://discourse.glfw.org/), and the `#glfw` IRC channel on -[Libera.Chat](https://libera.chat/). +[forum](https://discourse.glfw.org/). If you have a bug to report, a patch to submit or a feature you'd like to request, please file it in the [issue tracker](https://github.com/glfw/glfw/issues) on GitHub. Finally, if you're interested in helping out with the development of GLFW or -porting it to your favorite platform, join us on the forum, GitHub or IRC. +porting it to your favorite platform, join us on the forum or GitHub. diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 033c7800..17bb85e6 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -23,13 +23,12 @@ Questions about how to use GLFW should be asked either in the [support 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 -[Libera.Chat](https://libera.chat/). +Stack Exchange. Questions about the design or implementation of GLFW or about future plans 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. +forum. Please don't open a GitHub issue to discuss design questions without +first checking with a maintainer. ## Reporting a bug diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md index 79a45a8f..d9be56f7 100644 --- a/docs/SUPPORT.md +++ b/docs/SUPPORT.md @@ -4,8 +4,7 @@ See the [latest documentation](https://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 -[Libera.Chat](https://libera.chat/). +[forum](https://discourse.glfw.org/). Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues). Please check the [contribution From 42afff41fe019f7b4e7bd0fe5d6899de91ada1fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 29 Jan 2024 22:45:28 +0100 Subject: [PATCH 042/137] Remove reminders to use C99 from more source files --- src/cocoa_init.m | 2 -- src/cocoa_joystick.m | 2 -- src/cocoa_monitor.m | 2 -- src/cocoa_window.m | 2 -- src/nsgl_context.m | 2 -- 5 files changed, 10 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 6baf6b3f..e75a5519 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -23,8 +23,6 @@ // 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_joystick.m b/src/cocoa_joystick.m index caeb4725..d5de4793 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -24,8 +24,6 @@ // 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 6c7315bd..78089419 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -24,8 +24,6 @@ // 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 c865c09e..f6639646 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -23,8 +23,6 @@ // 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/nsgl_context.m b/src/nsgl_context.m index de89e421..e838caa2 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -23,8 +23,6 @@ // distribution. // //======================================================================== -// It is fine to use C99 in this file because it will not be built with VS -//======================================================================== #include "internal.h" From c47894a9a3d6cb240584e01091960c507762db36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 29 Jan 2024 22:47:04 +0100 Subject: [PATCH 043/137] Update compilation-related parts of README --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5bba59c7..fec484e2 100644 --- a/README.md +++ b/README.md @@ -47,18 +47,19 @@ features or fixing bugs. ## Compiling GLFW -GLFW itself requires only the headers and libraries for your OS and window -system. It does not need the headers for any context creation API (WGL, GLX, -EGL, NSGL, OSMesa) or rendering API (OpenGL, OpenGL ES, Vulkan) to enable -support for them. +GLFW is written primarily in C99, with parts of macOS support being written in +Objective-C. GLFW itself requires only the headers and libraries for your OS +and window system. It does not need any additional headers for context creation +APIs (WGL, GLX, EGL, NSGL, OSMesa) or rendering APIs (OpenGL, OpenGL ES, Vulkan) +to enable support for them. -GLFW supports compilation on Windows with Visual C++ 2010 and later, MinGW and +GLFW supports compilation on Windows with Visual C++ 2013 and later, MinGW and MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC and Clang. It will likely compile in other environments as well, but this is not regularly tested. -There are [pre-compiled Windows binaries](https://www.glfw.org/download.html) -available for all supported compilers. +There are [pre-compiled binaries](https://www.glfw.org/download.html) available +for all supported compilers on Windows and macOS. See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for more information about how to compile GLFW yourself. @@ -79,8 +80,6 @@ more information. ## System requirements -GLFW is written in C99 and does not support Visual Studio 2012 or earlier. - GLFW supports Windows XP and later and macOS 10.8 and later. Linux and other Unix-like systems running the X Window System are supported even without a desktop environment or modern extensions, although some features require From f74ff2aa10f926cf64ad9c4fd57a05c8004c8192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 18 Jan 2024 21:43:50 +0100 Subject: [PATCH 044/137] Fix function return value when uninitialized --- src/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input.c b/src/input.c index b5bb69d6..542fabe3 100644 --- a/src/input.c +++ b/src/input.c @@ -721,7 +721,7 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode) GLFWAPI int glfwGetKeyScancode(int key) { - _GLFW_REQUIRE_INIT_OR_RETURN(-1); + _GLFW_REQUIRE_INIT_OR_RETURN(0); if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST) { From d7aeb1eae85f9ea629aff719d4eadf31d51b6e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 18 Jan 2024 21:44:31 +0100 Subject: [PATCH 045/137] Fix function return value when uninitialized --- src/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window.c b/src/window.c index 1117df2f..51903e63 100644 --- a/src/window.c +++ b/src/window.c @@ -740,7 +740,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle) _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(1.f); + _GLFW_REQUIRE_INIT_OR_RETURN(0.f); return _glfw.platform.getWindowOpacity(window); } From 86d7bcb124e669e6de56c7208e6f3592d852819a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 19 Jan 2024 13:07:12 +0100 Subject: [PATCH 046/137] Fix missing checks for platform mismatch The native access functions for monitor objects did not check whether the correct platform was initialized and would return invalid handles if it was not. --- src/cocoa_monitor.m | 7 +++++++ src/win32_monitor.c | 14 ++++++++++++++ src/wl_monitor.c | 7 +++++++ src/x11_monitor.c | 14 ++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 78089419..e351088a 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -622,6 +622,13 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay); + + if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Cocoa: Platform not initialized"); + return kCGNullDirectDisplay; + } + return monitor->ns.displayID; } diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 13f7bfe7..4edaf2c3 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -535,6 +535,13 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Win32: Platform not initialized"); + return NULL; + } + return monitor->win32.publicAdapterName; } @@ -542,6 +549,13 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Win32: Platform not initialized"); + return NULL; + } + return monitor->win32.publicDisplayName; } diff --git a/src/wl_monitor.c b/src/wl_monitor.c index df64f603..96527a48 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -259,6 +259,13 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Wayland: Platform not initialized"); + return NULL; + } + return monitor->wl.output; } diff --git a/src/x11_monitor.c b/src/x11_monitor.c index ae626643..31640fb1 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -604,6 +604,13 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(None); + + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized"); + return None; + } + return monitor->x11.crtc; } @@ -611,6 +618,13 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(None); + + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "X11: Platform not initialized"); + return None; + } + return monitor->x11.output; } From 00e86d4b733103a23278fe53ce58a0d14dd47d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 30 Jan 2024 18:21:33 +0100 Subject: [PATCH 047/137] WGL: Fix pixel format count in a Parallels VM In a Parallels VM wglGetPixelFormatAttribivARB returns fewer pixel formats than DescribePixelFormat. This broke context creation on Windows in Parallels since the changes in 2c0f34b60f7c7a07183ed71754b0156ece3b6c1b. The previous version of the code worked accidentally. This adds a workaround by iterating through the minimum of both counts. It should have no effect when running on conforming implementations. Tested on Parallels by @ dougbinks. Closes #2191 Fixes #2406 Fixes #2467 --- CONTRIBUTORS.md | 2 ++ src/wgl_context.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 570b7707..6f426cdd 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -47,6 +47,7 @@ video tutorials. - Bailey Cosier - Noel Cower - CuriouserThing + - Bill Currie - Jason Daly - danhambleton - Jarrod Davis @@ -166,6 +167,7 @@ video tutorials. - Pascal Muetschard - James Murphy - Julian Møller + - NateIsStalling - ndogxj - F. Nedelec - n3rdopolis diff --git a/src/wgl_context.c b/src/wgl_context.c index 65d758af..8a23ffc4 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -115,6 +115,23 @@ static int choosePixelFormatWGL(_GLFWwindow* window, if (_glfw.wgl.EXT_colorspace) ADD_ATTRIB(WGL_COLORSPACE_EXT); } + + // NOTE: In a Parallels VM WGL_ARB_pixel_format returns fewer pixel formats than + // DescribePixelFormat, violating the guarantees of the extension spec + // HACK: Iterate through the minimum of both counts + + const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB; + int extensionCount; + + if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc, + 1, 0, 1, &attrib, &extensionCount)) + { + _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, + "WGL: Failed to retrieve pixel format attribute"); + return 0; + } + + nativeCount = _glfw_min(nativeCount, extensionCount); } usableConfigs = _glfw_calloc(nativeCount, sizeof(_GLFWfbconfig)); From eeb403135d91edb84e67b25ad69565a6b15b0d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 9 Feb 2024 13:06:26 +0100 Subject: [PATCH 048/137] Add minor features and updates to window test - Button label reflects window mode - Window attention request button - Slightly less bad button layout possibly - Applicable button labels list expected delay - Less telegraphic message for positions being unsupported - Window size more likely to fit contents --- tests/window.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/window.c b/tests/window.c index 83baff46..94c4f172 100644 --- a/tests/window.c +++ b/tests/window.c @@ -71,7 +71,7 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); - GLFWwindow* window = glfwCreateWindow(600, 600, "Window Features", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(600, 630, "Window Features", NULL, NULL); if (!window) { glfwTerminate(); @@ -121,17 +121,20 @@ int main(int argc, char** argv) nk_glfw3_new_frame(); if (nk_begin(nk, "main", area, 0)) { - nk_layout_row_dynamic(nk, 30, 5); + nk_layout_row_dynamic(nk, 30, 4); - if (nk_button_label(nk, "Toggle Fullscreen")) + if (glfwGetWindowMonitor(window)) { - if (glfwGetWindowMonitor(window)) + if (nk_button_label(nk, "Make Windowed")) { glfwSetWindowMonitor(window, NULL, windowed_x, windowed_y, windowed_width, windowed_height, 0); } - else + } + else + { + if (nk_button_label(nk, "Make Fullscreen")) { GLFWmonitor* monitor = glfwGetPrimaryMonitor(); const GLFWvidmode* mode = glfwGetVideoMode(monitor); @@ -149,7 +152,10 @@ int main(int argc, char** argv) glfwIconifyWindow(window); if (nk_button_label(nk, "Restore")) glfwRestoreWindow(window); - if (nk_button_label(nk, "Hide (briefly)")) + + nk_layout_row_dynamic(nk, 30, 2); + + if (nk_button_label(nk, "Hide (for 3s)")) { glfwHideWindow(window); @@ -159,6 +165,16 @@ int main(int argc, char** argv) glfwShowWindow(window); } + if (nk_button_label(nk, "Request Attention (after 3s)")) + { + glfwIconifyWindow(window); + + const double time = glfwGetTime() + 3.0; + while (glfwGetTime() < time) + glfwWaitEventsTimeout(1.0); + + glfwRequestWindowAttention(window); + } nk_layout_row_dynamic(nk, 30, 1); @@ -211,7 +227,7 @@ int main(int argc, char** argv) last_ypos = ypos; } else - nk_label(nk, "Position not supported", NK_TEXT_LEFT); + nk_label(nk, "Platform does not support window position", NK_TEXT_LEFT); nk_layout_row_dynamic(nk, 30, 3); nk_label(nk, "Size", NK_TEXT_LEFT); From a360198f8f983d7d85990748c411fb7a82654203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 9 Feb 2024 03:55:14 +0100 Subject: [PATCH 049/137] Wayland: Implement glfwFocusWindow This implements window focus requests via the xdg-activation-v1 protocol. These requests will likely only work when another window of the same application already has input focus, but that isn't unlike the behavior of other platforms. The GLFW_FEATURE_UNAVAILABLE error has been removed from this function for now. Related to #2284 Related to #2306 Related to #2439 --- README.md | 1 + docs/compat.dox | 5 ++--- include/GLFW/glfw3.h | 8 ++++---- src/wl_window.c | 32 ++++++++++++++++++++++++++++++-- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fec484e2..b23ca0ed 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread would abort (#1649) - [Wayland] Added support for `glfwRequestWindowAttention` (#2287) + [Wayland] Added support for `glfwFocusWindow` - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [X11] Bugfix: Termination would segfault if the IM had been destroyed diff --git a/docs/compat.dox b/docs/compat.dox index ddcd4dbc..66a92614 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -142,9 +142,8 @@ protocols either, no decorations will be drawn around windows. GLFW uses the [xdg-activation protocol](https://wayland.app/protocols/xdg-activation-v1) -to enable attention requests. This protocol is part of -wayland-protocols staging, and mandatory at build time. If the running compositor -does not support this protocol, the attention requests do nothing. +to implement window focus and attention requests. If the running compositor +does not support this protocol, window focus and attention requests do nothing. @section compat_glx GLX extensions diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 5e6fad42..6f8c9b41 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3856,11 +3856,11 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window); * * @param[in] window The window to give input focus. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @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. + * @remark @wayland The compositor will likely ignore focus requests unless + * another window created by the same application already has input focus. * * @thread_safety This function must only be called from the main thread. * diff --git a/src/wl_window.c b/src/wl_window.c index 981f2401..d7f12660 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2378,8 +2378,36 @@ void _glfwRequestWindowAttentionWayland(_GLFWwindow* window) void _glfwFocusWindowWayland(_GLFWwindow* window) { - _glfwInputError(GLFW_FEATURE_UNAVAILABLE, - "Wayland: The platform does not support setting the input focus"); + if (!_glfw.wl.activationManager) + return; + + if (window->wl.activationToken) + xdg_activation_token_v1_destroy(window->wl.activationToken); + + window->wl.activationToken = + xdg_activation_v1_get_activation_token(_glfw.wl.activationManager); + xdg_activation_token_v1_add_listener(window->wl.activationToken, + &xdgActivationListener, + window); + + xdg_activation_token_v1_set_serial(window->wl.activationToken, + _glfw.wl.serial, + _glfw.wl.seat); + + _GLFWwindow* requester = _glfw.wl.keyboardFocus; + if (requester) + { + xdg_activation_token_v1_set_surface(window->wl.activationToken, + requester->wl.surface); + + if (requester->wl.appId) + { + xdg_activation_token_v1_set_app_id(window->wl.activationToken, + requester->wl.appId); + } + } + + xdg_activation_token_v1_commit(window->wl.activationToken); } void _glfwSetWindowMonitorWayland(_GLFWwindow* window, From 1fe98a0d5388435720d380439497630ac0477455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 9 Feb 2024 13:58:49 +0100 Subject: [PATCH 050/137] Fix missing list entry dash in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b23ca0ed..49b1d912 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread would abort (#1649) - [Wayland] Added support for `glfwRequestWindowAttention` (#2287) - [Wayland] Added support for `glfwFocusWindow` + - [Wayland] Added support for `glfwFocusWindow` - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [X11] Bugfix: Termination would segfault if the IM had been destroyed From d3a7362430a2a0073009c8f4ca9fd4e494b0418f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 21:34:15 +0100 Subject: [PATCH 051/137] Wayland: Separate window and framebuffer resizing --- src/wl_window.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index d7f12660..94970d14 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -306,8 +306,7 @@ static void setContentAreaOpaque(_GLFWwindow* window) wl_region_destroy(region); } - -static void resizeWindow(_GLFWwindow* window) +static void resizeFramebuffer(_GLFWwindow* window) { int scale = window->wl.contentScale; int scaledWidth = window->wl.width * scale; @@ -315,9 +314,16 @@ static void resizeWindow(_GLFWwindow* window) if (window->wl.egl.window) wl_egl_window_resize(window->wl.egl.window, scaledWidth, scaledHeight, 0, 0); + if (!window->wl.transparent) setContentAreaOpaque(window); + _glfwInputFramebufferSize(window, scaledWidth, scaledHeight); +} + +static void resizeWindow(_GLFWwindow* window) +{ + resizeFramebuffer(window); if (!window->wl.decorations.top.surface) return; @@ -363,7 +369,7 @@ void _glfwUpdateContentScaleWayland(_GLFWwindow* window) window->wl.contentScale = maxScale; wl_surface_set_buffer_scale(window->wl.surface, maxScale); _glfwInputWindowContentScale(window, maxScale, maxScale); - resizeWindow(window); + resizeFramebuffer(window); if (window->wl.visible) _glfwInputWindowDamage(window); From 5e97447dd586016b4b82aefa7e1981694176a898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 21:55:20 +0100 Subject: [PATCH 052/137] Wayland: Clarify fallback decoration struct name We now have three window decoration paths in the Wayland backend: libdecor decorations, XDG decorations and fallback decorations. This makes it clearer when code relates to the fallback decoration path, which should increasingly (hopefully) not get used. --- src/wl_platform.h | 2 +- src/wl_window.c | 100 +++++++++++++++++++++++----------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index 7e8202e9..6da294fc 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -414,7 +414,7 @@ typedef struct _GLFWwindowWayland struct wl_buffer* buffer; _GLFWdecorationWayland top, left, right, bottom; _GLFWdecorationSideWayland focus; - } decorations; + } fallback; } _GLFWwindowWayland; // Wayland-specific global data diff --git a/src/wl_window.c b/src/wl_window.c index 94970d14..31c3b7e5 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -226,25 +226,25 @@ static void createFallbackDecorations(_GLFWwindow* window) if (!_glfw.wl.viewporter) return; - if (!window->wl.decorations.buffer) - window->wl.decorations.buffer = createShmBuffer(&image); - if (!window->wl.decorations.buffer) + if (!window->wl.fallback.buffer) + window->wl.fallback.buffer = createShmBuffer(&image); + if (!window->wl.fallback.buffer) return; - createFallbackDecoration(window, &window->wl.decorations.top, window->wl.surface, - window->wl.decorations.buffer, + createFallbackDecoration(window, &window->wl.fallback.top, window->wl.surface, + window->wl.fallback.buffer, 0, -GLFW_CAPTION_HEIGHT, window->wl.width, GLFW_CAPTION_HEIGHT); - createFallbackDecoration(window, &window->wl.decorations.left, window->wl.surface, - window->wl.decorations.buffer, + createFallbackDecoration(window, &window->wl.fallback.left, window->wl.surface, + window->wl.fallback.buffer, -GLFW_BORDER_SIZE, -GLFW_CAPTION_HEIGHT, GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - createFallbackDecoration(window, &window->wl.decorations.right, window->wl.surface, - window->wl.decorations.buffer, + createFallbackDecoration(window, &window->wl.fallback.right, window->wl.surface, + window->wl.fallback.buffer, window->wl.width, -GLFW_CAPTION_HEIGHT, GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - createFallbackDecoration(window, &window->wl.decorations.bottom, window->wl.surface, - window->wl.decorations.buffer, + createFallbackDecoration(window, &window->wl.fallback.bottom, window->wl.surface, + window->wl.fallback.buffer, -GLFW_BORDER_SIZE, window->wl.height, window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE); } @@ -264,10 +264,10 @@ static void destroyFallbackDecoration(_GLFWdecorationWayland* decoration) static void destroyFallbackDecorations(_GLFWwindow* window) { - destroyFallbackDecoration(&window->wl.decorations.top); - destroyFallbackDecoration(&window->wl.decorations.left); - destroyFallbackDecoration(&window->wl.decorations.right); - destroyFallbackDecoration(&window->wl.decorations.bottom); + destroyFallbackDecoration(&window->wl.fallback.top); + destroyFallbackDecoration(&window->wl.fallback.left); + destroyFallbackDecoration(&window->wl.fallback.right); + destroyFallbackDecoration(&window->wl.fallback.bottom); } static void xdgDecorationHandleConfigure(void* userData, @@ -325,28 +325,28 @@ static void resizeWindow(_GLFWwindow* window) { resizeFramebuffer(window); - if (!window->wl.decorations.top.surface) + if (!window->wl.fallback.top.surface) return; - wp_viewport_set_destination(window->wl.decorations.top.viewport, + wp_viewport_set_destination(window->wl.fallback.top.viewport, window->wl.width, GLFW_CAPTION_HEIGHT); - wl_surface_commit(window->wl.decorations.top.surface); + wl_surface_commit(window->wl.fallback.top.surface); - wp_viewport_set_destination(window->wl.decorations.left.viewport, + wp_viewport_set_destination(window->wl.fallback.left.viewport, GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - wl_surface_commit(window->wl.decorations.left.surface); + wl_surface_commit(window->wl.fallback.left.surface); - wl_subsurface_set_position(window->wl.decorations.right.subsurface, + wl_subsurface_set_position(window->wl.fallback.right.subsurface, window->wl.width, -GLFW_CAPTION_HEIGHT); - wp_viewport_set_destination(window->wl.decorations.right.viewport, + wp_viewport_set_destination(window->wl.fallback.right.viewport, GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - wl_surface_commit(window->wl.decorations.right.surface); + wl_surface_commit(window->wl.fallback.right.surface); - wl_subsurface_set_position(window->wl.decorations.bottom.subsurface, + wl_subsurface_set_position(window->wl.fallback.bottom.subsurface, -GLFW_BORDER_SIZE, window->wl.height); - wp_viewport_set_destination(window->wl.decorations.bottom.viewport, + wp_viewport_set_destination(window->wl.fallback.bottom.viewport, window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE); - wl_surface_commit(window->wl.decorations.bottom.surface); + wl_surface_commit(window->wl.fallback.bottom.surface); } void _glfwUpdateContentScaleWayland(_GLFWwindow* window) @@ -466,7 +466,7 @@ static void acquireMonitor(_GLFWwindow* window) setIdleInhibitor(window, GLFW_TRUE); - if (window->wl.decorations.top.surface) + if (window->wl.fallback.top.surface) destroyFallbackDecorations(window); } @@ -522,7 +522,7 @@ static void xdgToplevelHandleConfigure(void* userData, if (width && height) { - if (window->wl.decorations.top.surface) + if (window->wl.fallback.top.surface) { window->wl.pending.width = _glfw_max(0, width - GLFW_BORDER_SIZE * 2); window->wl.pending.height = @@ -882,7 +882,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) int minwidth = window->minwidth; int minheight = window->minheight; - if (window->wl.decorations.top.surface) + if (window->wl.fallback.top.surface) { minwidth += GLFW_BORDER_SIZE * 2; minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; @@ -896,7 +896,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) int maxwidth = window->maxwidth; int maxheight = window->maxheight; - if (window->wl.decorations.top.surface) + if (window->wl.fallback.top.surface) { maxwidth += GLFW_BORDER_SIZE * 2; maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; @@ -1025,7 +1025,7 @@ static void incrementCursorImage(_GLFWwindow* window) { _GLFWcursor* cursor; - if (!window || window->wl.decorations.focus != GLFW_MAIN_WINDOW) + if (!window || window->wl.fallback.focus != GLFW_MAIN_WINDOW) return; cursor = window->wl.currentCursor; @@ -1276,16 +1276,16 @@ static void pointerHandleEnter(void* userData, _GLFWwindow* window = wl_surface_get_user_data(surface); - if (surface == window->wl.decorations.top.surface) - window->wl.decorations.focus = GLFW_TOP_DECORATION; - else if (surface == window->wl.decorations.left.surface) - window->wl.decorations.focus = GLFW_LEFT_DECORATION; - else if (surface == window->wl.decorations.right.surface) - window->wl.decorations.focus = GLFW_RIGHT_DECORATION; - else if (surface == window->wl.decorations.bottom.surface) - window->wl.decorations.focus = GLFW_BOTTOM_DECORATION; + if (surface == window->wl.fallback.top.surface) + window->wl.fallback.focus = GLFW_TOP_DECORATION; + else if (surface == window->wl.fallback.left.surface) + window->wl.fallback.focus = GLFW_LEFT_DECORATION; + else if (surface == window->wl.fallback.right.surface) + window->wl.fallback.focus = GLFW_RIGHT_DECORATION; + else if (surface == window->wl.fallback.bottom.surface) + window->wl.fallback.focus = GLFW_BOTTOM_DECORATION; else - window->wl.decorations.focus = GLFW_MAIN_WINDOW; + window->wl.fallback.focus = GLFW_MAIN_WINDOW; _glfw.wl.serial = serial; _glfw.wl.pointerEnterSerial = serial; @@ -1340,7 +1340,7 @@ static void pointerHandleMotion(void* userData, const char* cursorName = NULL; - switch (window->wl.decorations.focus) + switch (window->wl.fallback.focus) { case GLFW_MAIN_WINDOW: _glfw.wl.cursorPreviousName = NULL; @@ -1431,7 +1431,7 @@ static void pointerHandleButton(void* userData, return; if (button == BTN_LEFT) { - switch (window->wl.decorations.focus) + switch (window->wl.fallback.focus) { case GLFW_MAIN_WINDOW: break; @@ -1473,7 +1473,7 @@ static void pointerHandleButton(void* userData, } else if (button == BTN_RIGHT) { - if (window->wl.decorations.focus != GLFW_MAIN_WINDOW && + if (window->wl.fallback.focus != GLFW_MAIN_WINDOW && window->wl.xdg.toplevel) { xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, @@ -1485,7 +1485,7 @@ static void pointerHandleButton(void* userData, } // Don’t pass the button to the user if it was related to a decoration. - if (window->wl.decorations.focus != GLFW_MAIN_WINDOW) + if (window->wl.fallback.focus != GLFW_MAIN_WINDOW) return; _glfw.wl.serial = serial; @@ -2100,8 +2100,8 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) destroyShellObjects(window); - if (window->wl.decorations.buffer) - wl_buffer_destroy(window->wl.decorations.buffer); + if (window->wl.fallback.buffer) + wl_buffer_destroy(window->wl.fallback.buffer); if (window->wl.egl.window) wl_egl_window_destroy(window->wl.egl.window); @@ -2205,7 +2205,7 @@ void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, minwidth = minheight = 0; else { - if (window->wl.decorations.top.surface) + if (window->wl.fallback.top.surface) { minwidth += GLFW_BORDER_SIZE * 2; minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; @@ -2216,7 +2216,7 @@ void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, maxwidth = maxheight = 0; else { - if (window->wl.decorations.top.surface) + if (window->wl.fallback.top.surface) { maxwidth += GLFW_BORDER_SIZE * 2; maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; @@ -2279,7 +2279,7 @@ void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, int* left, int* top, int* right, int* bottom) { - if (window->wl.decorations.top.surface) + if (window->wl.fallback.top.surface) { if (top) *top = GLFW_CAPTION_HEIGHT; @@ -2926,7 +2926,7 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) // If we're not in the correct window just save the cursor // the next time the pointer enters the window the cursor will change if (window != _glfw.wl.pointerFocus || - window->wl.decorations.focus != GLFW_MAIN_WINDOW) + window->wl.fallback.focus != GLFW_MAIN_WINDOW) { return; } From ea6dd72c714f6f3949cfaf21ad5c1745d4fb49d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 22:21:52 +0100 Subject: [PATCH 053/137] Wayland: Fix GLFW_HOVERED for fallback decorations When using the fallback decorations, GLFW_HOVERED was true also when the cursor was over one of the window decorations. This also disentangles the GLFW_HOVERED state from the fallback decorations. Because GLFW_HOVERED should have had the same behavior as GLFW_MAIN_WINDOW, the latter has been removed. --- README.md | 2 ++ src/wl_platform.h | 1 - src/wl_window.c | 84 +++++++++++++++++++++++------------------------ 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 49b1d912..177960f6 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,8 @@ information on what to include when reporting a bug. - [Wayland] Added support for `glfwFocusWindow` - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled + - [Wayland] Bugfix: `GLFW_HOVERED` was true when the cursor was over any + fallback window decoration - [X11] Bugfix: Termination would segfault if the IM had been destroyed - [X11] Bugfix: Any IM started after initialization would not be detected - [POSIX] Removed use of deprecated function `gettimeofday` diff --git a/src/wl_platform.h b/src/wl_platform.h index 6da294fc..ba7616ec 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -325,7 +325,6 @@ typedef void (* PFN_libdecor_state_free)(struct libdecor_state*); typedef enum _GLFWdecorationSideWayland { - GLFW_MAIN_WINDOW, GLFW_TOP_DECORATION, GLFW_LEFT_DECORATION, GLFW_RIGHT_DECORATION, diff --git a/src/wl_window.c b/src/wl_window.c index 31c3b7e5..a2e13c22 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1025,7 +1025,7 @@ static void incrementCursorImage(_GLFWwindow* window) { _GLFWcursor* cursor; - if (!window || window->wl.fallback.focus != GLFW_MAIN_WINDOW) + if (!window || !window->wl.hovered) return; cursor = window->wl.currentCursor; @@ -1276,7 +1276,9 @@ static void pointerHandleEnter(void* userData, _GLFWwindow* window = wl_surface_get_user_data(surface); - if (surface == window->wl.fallback.top.surface) + if (surface == window->wl.surface) + window->wl.hovered = GLFW_TRUE; + else if (surface == window->wl.fallback.top.surface) window->wl.fallback.focus = GLFW_TOP_DECORATION; else if (surface == window->wl.fallback.left.surface) window->wl.fallback.focus = GLFW_LEFT_DECORATION; @@ -1284,17 +1286,16 @@ static void pointerHandleEnter(void* userData, window->wl.fallback.focus = GLFW_RIGHT_DECORATION; else if (surface == window->wl.fallback.bottom.surface) window->wl.fallback.focus = GLFW_BOTTOM_DECORATION; - else - window->wl.fallback.focus = GLFW_MAIN_WINDOW; _glfw.wl.serial = serial; _glfw.wl.pointerEnterSerial = serial; _glfw.wl.pointerFocus = window; - window->wl.hovered = GLFW_TRUE; - - _glfwSetCursorWayland(window, window->wl.currentCursor); - _glfwInputCursorEnter(window, GLFW_TRUE); + if (window->wl.hovered) + { + _glfwSetCursorWayland(window, window->wl.currentCursor); + _glfwInputCursorEnter(window, GLFW_TRUE); + } } static void pointerHandleLeave(void* userData, @@ -1312,12 +1313,15 @@ static void pointerHandleLeave(void* userData, if (!window) return; - window->wl.hovered = GLFW_FALSE; - _glfw.wl.serial = serial; _glfw.wl.pointerFocus = NULL; _glfw.wl.cursorPreviousName = NULL; - _glfwInputCursorEnter(window, GLFW_FALSE); + + if (window->wl.hovered) + { + window->wl.hovered = GLFW_FALSE; + _glfwInputCursorEnter(window, GLFW_FALSE); + } } static void pointerHandleMotion(void* userData, @@ -1338,14 +1342,17 @@ static void pointerHandleMotion(void* userData, window->wl.cursorPosX = xpos; window->wl.cursorPosY = ypos; + if (window->wl.hovered) + { + _glfw.wl.cursorPreviousName = NULL; + _glfwInputCursorPos(window, xpos, ypos); + return; + } + const char* cursorName = NULL; switch (window->wl.fallback.focus) { - case GLFW_MAIN_WINDOW: - _glfw.wl.cursorPreviousName = NULL; - _glfwInputCursorPos(window, xpos, ypos); - return; case GLFW_TOP_DECORATION: if (ypos < GLFW_BORDER_SIZE) cursorName = "n-resize"; @@ -1429,12 +1436,28 @@ static void pointerHandleButton(void* userData, if (!window) return; + + if (window->wl.hovered) + { + _glfw.wl.serial = serial; + + /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev + * codes. */ + glfwButton = button - BTN_LEFT; + + _glfwInputMouseClick(window, + glfwButton, + state == WL_POINTER_BUTTON_STATE_PRESSED + ? GLFW_PRESS + : GLFW_RELEASE, + _glfw.wl.xkb.modifiers); + return; + } + if (button == BTN_LEFT) { switch (window->wl.fallback.focus) { - case GLFW_MAIN_WINDOW: - break; case GLFW_TOP_DECORATION: if (window->wl.cursorPosY < GLFW_BORDER_SIZE) edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; @@ -1468,38 +1491,18 @@ static void pointerHandleButton(void* userData, { xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, serial, edges); - return; } } else if (button == BTN_RIGHT) { - if (window->wl.fallback.focus != GLFW_MAIN_WINDOW && - window->wl.xdg.toplevel) + if (window->wl.xdg.toplevel) { xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, _glfw.wl.seat, serial, window->wl.cursorPosX, window->wl.cursorPosY); - return; } } - - // Don’t pass the button to the user if it was related to a decoration. - if (window->wl.fallback.focus != GLFW_MAIN_WINDOW) - return; - - _glfw.wl.serial = serial; - - /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev - * codes. */ - glfwButton = button - BTN_LEFT; - - _glfwInputMouseClick(window, - glfwButton, - state == WL_POINTER_BUTTON_STATE_PRESSED - ? GLFW_PRESS - : GLFW_RELEASE, - _glfw.wl.xkb.modifiers); } static void pointerHandleAxis(void* userData, @@ -2925,11 +2928,8 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) // If we're not in the correct window just save the cursor // the next time the pointer enters the window the cursor will change - if (window != _glfw.wl.pointerFocus || - window->wl.fallback.focus != GLFW_MAIN_WINDOW) - { + if (!window->wl.hovered) return; - } // Update pointer lock to match cursor mode if (window->cursorMode == GLFW_CURSOR_DISABLED) From 6ac0835ad2a98925bda1c855937340dc160f1db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 8 Feb 2024 00:05:29 +0100 Subject: [PATCH 054/137] Wayland: Cleanup --- src/wl_window.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index a2e13c22..712c58b4 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1431,9 +1431,6 @@ static void pointerHandleButton(void* userData, uint32_t state) { _GLFWwindow* window = _glfw.wl.pointerFocus; - int glfwButton; - uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; - if (!window) return; @@ -1441,21 +1438,17 @@ static void pointerHandleButton(void* userData, { _glfw.wl.serial = serial; - /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev - * codes. */ - glfwButton = button - BTN_LEFT; - _glfwInputMouseClick(window, - glfwButton, - state == WL_POINTER_BUTTON_STATE_PRESSED - ? GLFW_PRESS - : GLFW_RELEASE, - _glfw.wl.xkb.modifiers); + button - BTN_LEFT, + state == WL_POINTER_BUTTON_STATE_PRESSED, + _glfw.wl.xkb.modifiers); return; } if (button == BTN_LEFT) { + uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; + switch (window->wl.fallback.focus) { case GLFW_TOP_DECORATION: @@ -1484,8 +1477,6 @@ static void pointerHandleButton(void* userData, else edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; break; - default: - assert(0); } if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) { From 4baeadbd667d5a933f47b9669250409d4fb27d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 22:56:18 +0100 Subject: [PATCH 055/137] Wayland: Put fallback decorations behind a boolean --- src/wl_platform.h | 1 + src/wl_window.c | 300 ++++++++++++++++++++++++---------------------- 2 files changed, 159 insertions(+), 142 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index ba7616ec..e880d520 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -410,6 +410,7 @@ typedef struct _GLFWwindowWayland struct xdg_activation_token_v1* activationToken; struct { + GLFWbool decorations; struct wl_buffer* buffer; _GLFWdecorationWayland top, left, right, bottom; _GLFWdecorationSideWayland focus; diff --git a/src/wl_window.c b/src/wl_window.c index 712c58b4..c4d96b80 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -247,6 +247,8 @@ static void createFallbackDecorations(_GLFWwindow* window) window->wl.fallback.buffer, -GLFW_BORDER_SIZE, window->wl.height, window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE); + + window->wl.fallback.decorations = GLFW_TRUE; } static void destroyFallbackDecoration(_GLFWdecorationWayland* decoration) @@ -264,6 +266,8 @@ static void destroyFallbackDecoration(_GLFWdecorationWayland* decoration) static void destroyFallbackDecorations(_GLFWwindow* window) { + window->wl.fallback.decorations = GLFW_FALSE; + destroyFallbackDecoration(&window->wl.fallback.top); destroyFallbackDecoration(&window->wl.fallback.left); destroyFallbackDecoration(&window->wl.fallback.right); @@ -325,28 +329,32 @@ static void resizeWindow(_GLFWwindow* window) { resizeFramebuffer(window); - if (!window->wl.fallback.top.surface) - return; + if (window->wl.fallback.decorations) + { + wp_viewport_set_destination(window->wl.fallback.top.viewport, + window->wl.width, + GLFW_CAPTION_HEIGHT); + wl_surface_commit(window->wl.fallback.top.surface); - wp_viewport_set_destination(window->wl.fallback.top.viewport, - window->wl.width, GLFW_CAPTION_HEIGHT); - wl_surface_commit(window->wl.fallback.top.surface); + wp_viewport_set_destination(window->wl.fallback.left.viewport, + GLFW_BORDER_SIZE, + window->wl.height + GLFW_CAPTION_HEIGHT); + wl_surface_commit(window->wl.fallback.left.surface); - wp_viewport_set_destination(window->wl.fallback.left.viewport, - GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - wl_surface_commit(window->wl.fallback.left.surface); + wl_subsurface_set_position(window->wl.fallback.right.subsurface, + window->wl.width, -GLFW_CAPTION_HEIGHT); + wp_viewport_set_destination(window->wl.fallback.right.viewport, + GLFW_BORDER_SIZE, + window->wl.height + GLFW_CAPTION_HEIGHT); + wl_surface_commit(window->wl.fallback.right.surface); - wl_subsurface_set_position(window->wl.fallback.right.subsurface, - window->wl.width, -GLFW_CAPTION_HEIGHT); - wp_viewport_set_destination(window->wl.fallback.right.viewport, - GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - wl_surface_commit(window->wl.fallback.right.surface); - - wl_subsurface_set_position(window->wl.fallback.bottom.subsurface, - -GLFW_BORDER_SIZE, window->wl.height); - wp_viewport_set_destination(window->wl.fallback.bottom.viewport, - window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE); - wl_surface_commit(window->wl.fallback.bottom.surface); + wl_subsurface_set_position(window->wl.fallback.bottom.subsurface, + -GLFW_BORDER_SIZE, window->wl.height); + wp_viewport_set_destination(window->wl.fallback.bottom.viewport, + window->wl.width + GLFW_BORDER_SIZE * 2, + GLFW_BORDER_SIZE); + wl_surface_commit(window->wl.fallback.bottom.surface); + } } void _glfwUpdateContentScaleWayland(_GLFWwindow* window) @@ -466,7 +474,7 @@ static void acquireMonitor(_GLFWwindow* window) setIdleInhibitor(window, GLFW_TRUE); - if (window->wl.fallback.top.surface) + if (window->wl.fallback.decorations) destroyFallbackDecorations(window); } @@ -522,7 +530,7 @@ static void xdgToplevelHandleConfigure(void* userData, if (width && height) { - if (window->wl.fallback.top.surface) + if (window->wl.fallback.decorations) { window->wl.pending.width = _glfw_max(0, width - GLFW_BORDER_SIZE * 2); window->wl.pending.height = @@ -882,7 +890,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) int minwidth = window->minwidth; int minheight = window->minheight; - if (window->wl.fallback.top.surface) + if (window->wl.fallback.decorations) { minwidth += GLFW_BORDER_SIZE * 2; minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; @@ -896,7 +904,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) int maxwidth = window->maxwidth; int maxheight = window->maxheight; - if (window->wl.fallback.top.surface) + if (window->wl.fallback.decorations) { maxwidth += GLFW_BORDER_SIZE * 2; maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; @@ -1276,23 +1284,25 @@ static void pointerHandleEnter(void* userData, _GLFWwindow* window = wl_surface_get_user_data(surface); - if (surface == window->wl.surface) - window->wl.hovered = GLFW_TRUE; - else if (surface == window->wl.fallback.top.surface) - window->wl.fallback.focus = GLFW_TOP_DECORATION; - else if (surface == window->wl.fallback.left.surface) - window->wl.fallback.focus = GLFW_LEFT_DECORATION; - else if (surface == window->wl.fallback.right.surface) - window->wl.fallback.focus = GLFW_RIGHT_DECORATION; - else if (surface == window->wl.fallback.bottom.surface) - window->wl.fallback.focus = GLFW_BOTTOM_DECORATION; + if (window->wl.fallback.decorations) + { + if (surface == window->wl.fallback.top.surface) + window->wl.fallback.focus = GLFW_TOP_DECORATION; + else if (surface == window->wl.fallback.left.surface) + window->wl.fallback.focus = GLFW_LEFT_DECORATION; + else if (surface == window->wl.fallback.right.surface) + window->wl.fallback.focus = GLFW_RIGHT_DECORATION; + else if (surface == window->wl.fallback.bottom.surface) + window->wl.fallback.focus = GLFW_BOTTOM_DECORATION; + } _glfw.wl.serial = serial; _glfw.wl.pointerEnterSerial = serial; _glfw.wl.pointerFocus = window; - if (window->wl.hovered) + if (surface == window->wl.surface) { + window->wl.hovered = GLFW_TRUE; _glfwSetCursorWayland(window, window->wl.currentCursor); _glfwInputCursorEnter(window, GLFW_TRUE); } @@ -1349,77 +1359,80 @@ static void pointerHandleMotion(void* userData, return; } - const char* cursorName = NULL; - - switch (window->wl.fallback.focus) + if (window->wl.fallback.decorations) { - case GLFW_TOP_DECORATION: - if (ypos < GLFW_BORDER_SIZE) - cursorName = "n-resize"; - else - cursorName = "left_ptr"; - break; - case GLFW_LEFT_DECORATION: - if (ypos < GLFW_BORDER_SIZE) - cursorName = "nw-resize"; - else - cursorName = "w-resize"; - break; - case GLFW_RIGHT_DECORATION: - if (ypos < GLFW_BORDER_SIZE) - cursorName = "ne-resize"; - else - cursorName = "e-resize"; - break; - case GLFW_BOTTOM_DECORATION: - if (xpos < GLFW_BORDER_SIZE) - cursorName = "sw-resize"; - else if (xpos > window->wl.width + GLFW_BORDER_SIZE) - cursorName = "se-resize"; - else - cursorName = "s-resize"; - break; - default: - assert(0); - } + const char* cursorName = NULL; - if (_glfw.wl.cursorPreviousName != cursorName) - { - struct wl_surface* surface = _glfw.wl.cursorSurface; - struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; - int scale = 1; - - if (window->wl.contentScale > 1 && _glfw.wl.cursorThemeHiDPI) + switch (window->wl.fallback.focus) { - // We only support up to scale=2 for now, since libwayland-cursor - // requires us to load a different theme for each size. - scale = 2; - theme = _glfw.wl.cursorThemeHiDPI; + case GLFW_TOP_DECORATION: + if (ypos < GLFW_BORDER_SIZE) + cursorName = "n-resize"; + else + cursorName = "left_ptr"; + break; + case GLFW_LEFT_DECORATION: + if (ypos < GLFW_BORDER_SIZE) + cursorName = "nw-resize"; + else + cursorName = "w-resize"; + break; + case GLFW_RIGHT_DECORATION: + if (ypos < GLFW_BORDER_SIZE) + cursorName = "ne-resize"; + else + cursorName = "e-resize"; + break; + case GLFW_BOTTOM_DECORATION: + if (xpos < GLFW_BORDER_SIZE) + cursorName = "sw-resize"; + else if (xpos > window->wl.width + GLFW_BORDER_SIZE) + cursorName = "se-resize"; + else + cursorName = "s-resize"; + break; + default: + assert(0); } - struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName); - if (!cursor) - return; + if (_glfw.wl.cursorPreviousName != cursorName) + { + struct wl_surface* surface = _glfw.wl.cursorSurface; + struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; + int scale = 1; - // TODO: handle animated cursors too. - struct wl_cursor_image* image = cursor->images[0]; - if (!image) - return; + if (window->wl.contentScale > 1 && _glfw.wl.cursorThemeHiDPI) + { + // We only support up to scale=2 for now, since libwayland-cursor + // requires us to load a different theme for each size. + scale = 2; + theme = _glfw.wl.cursorThemeHiDPI; + } - struct wl_buffer* buffer = wl_cursor_image_get_buffer(image); - if (!buffer) - return; + struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName); + if (!cursor) + return; - wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, - surface, - image->hotspot_x / scale, - image->hotspot_y / scale); - wl_surface_set_buffer_scale(surface, scale); - wl_surface_attach(surface, buffer, 0, 0); - wl_surface_damage(surface, 0, 0, image->width, image->height); - wl_surface_commit(surface); + // TODO: handle animated cursors too. + struct wl_cursor_image* image = cursor->images[0]; + if (!image) + return; - _glfw.wl.cursorPreviousName = cursorName; + struct wl_buffer* buffer = wl_cursor_image_get_buffer(image); + if (!buffer) + return; + + wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, + surface, + image->hotspot_x / scale, + image->hotspot_y / scale); + wl_surface_set_buffer_scale(surface, scale); + wl_surface_attach(surface, buffer, 0, 0); + wl_surface_damage(surface, 0, 0, image->width, image->height); + wl_surface_commit(surface); + + _glfw.wl.cursorPreviousName = cursorName; + } } } @@ -1445,53 +1458,56 @@ static void pointerHandleButton(void* userData, return; } - if (button == BTN_LEFT) + if (window->wl.fallback.decorations) { - uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; + if (button == BTN_LEFT) + { + uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; - switch (window->wl.fallback.focus) - { - case GLFW_TOP_DECORATION: - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; - else - xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); - break; - case GLFW_LEFT_DECORATION: - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; - break; - case GLFW_RIGHT_DECORATION: - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; - break; - case GLFW_BOTTOM_DECORATION: - if (window->wl.cursorPosX < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; - else if (window->wl.cursorPosX > window->wl.width + GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; - break; + switch (window->wl.fallback.focus) + { + case GLFW_TOP_DECORATION: + if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; + else + xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); + break; + case GLFW_LEFT_DECORATION: + if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; + break; + case GLFW_RIGHT_DECORATION: + if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; + break; + case GLFW_BOTTOM_DECORATION: + if (window->wl.cursorPosX < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; + else if (window->wl.cursorPosX > window->wl.width + GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; + break; + } + if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) + { + xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, + serial, edges); + } } - if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) + else if (button == BTN_RIGHT) { - xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, - serial, edges); - } - } - else if (button == BTN_RIGHT) - { - if (window->wl.xdg.toplevel) - { - xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, - _glfw.wl.seat, serial, - window->wl.cursorPosX, - window->wl.cursorPosY); + if (window->wl.xdg.toplevel) + { + xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, + _glfw.wl.seat, serial, + window->wl.cursorPosX, + window->wl.cursorPosY); + } } } } @@ -2199,7 +2215,7 @@ void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, minwidth = minheight = 0; else { - if (window->wl.fallback.top.surface) + if (window->wl.fallback.decorations) { minwidth += GLFW_BORDER_SIZE * 2; minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; @@ -2210,7 +2226,7 @@ void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, maxwidth = maxheight = 0; else { - if (window->wl.fallback.top.surface) + if (window->wl.fallback.decorations) { maxwidth += GLFW_BORDER_SIZE * 2; maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; @@ -2273,7 +2289,7 @@ void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, int* left, int* top, int* right, int* bottom) { - if (window->wl.fallback.top.surface) + if (window->wl.fallback.decorations) { if (top) *top = GLFW_CAPTION_HEIGHT; From a268b4b3a45ecda64c04dff10c5d9dd603149b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 23:56:03 +0100 Subject: [PATCH 056/137] Wayland: Cleanup --- src/wl_platform.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index e880d520..eb361027 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -406,14 +406,14 @@ typedef struct _GLFWwindowWayland struct zwp_locked_pointer_v1* lockedPointer; struct zwp_confined_pointer_v1* confinedPointer; - struct zwp_idle_inhibitor_v1* idleInhibitor; - struct xdg_activation_token_v1* activationToken; + struct zwp_idle_inhibitor_v1* idleInhibitor; + struct xdg_activation_token_v1* activationToken; struct { GLFWbool decorations; - struct wl_buffer* buffer; - _GLFWdecorationWayland top, left, right, bottom; - _GLFWdecorationSideWayland focus; + struct wl_buffer* buffer; + _GLFWdecorationWayland top, left, right, bottom; + _GLFWdecorationSideWayland focus; } fallback; } _GLFWwindowWayland; From 72164e6921fb0e333d773a0fdf93aa791792593f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 8 Feb 2024 00:22:26 +0100 Subject: [PATCH 057/137] Wayland: Remove fallback decoration edge enum --- src/wl_platform.h | 10 +--- src/wl_window.c | 135 +++++++++++++++++++++++----------------------- 2 files changed, 68 insertions(+), 77 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index eb361027..0d5d3dfd 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -323,14 +323,6 @@ typedef void (* PFN_libdecor_state_free)(struct libdecor_state*); #define libdecor_state_new _glfw.wl.libdecor.libdecor_state_new_ #define libdecor_state_free _glfw.wl.libdecor.libdecor_state_free_ -typedef enum _GLFWdecorationSideWayland -{ - GLFW_TOP_DECORATION, - GLFW_LEFT_DECORATION, - GLFW_RIGHT_DECORATION, - GLFW_BOTTOM_DECORATION -} _GLFWdecorationSideWayland; - typedef struct _GLFWdecorationWayland { struct wl_surface* surface; @@ -413,7 +405,7 @@ typedef struct _GLFWwindowWayland GLFWbool decorations; struct wl_buffer* buffer; _GLFWdecorationWayland top, left, right, bottom; - _GLFWdecorationSideWayland focus; + struct wl_surface* focus; } fallback; } _GLFWwindowWayland; diff --git a/src/wl_window.c b/src/wl_window.c index c4d96b80..4071b4a5 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1284,18 +1284,6 @@ static void pointerHandleEnter(void* userData, _GLFWwindow* window = wl_surface_get_user_data(surface); - if (window->wl.fallback.decorations) - { - if (surface == window->wl.fallback.top.surface) - window->wl.fallback.focus = GLFW_TOP_DECORATION; - else if (surface == window->wl.fallback.left.surface) - window->wl.fallback.focus = GLFW_LEFT_DECORATION; - else if (surface == window->wl.fallback.right.surface) - window->wl.fallback.focus = GLFW_RIGHT_DECORATION; - else if (surface == window->wl.fallback.bottom.surface) - window->wl.fallback.focus = GLFW_BOTTOM_DECORATION; - } - _glfw.wl.serial = serial; _glfw.wl.pointerEnterSerial = serial; _glfw.wl.pointerFocus = window; @@ -1306,6 +1294,11 @@ static void pointerHandleEnter(void* userData, _glfwSetCursorWayland(window, window->wl.currentCursor); _glfwInputCursorEnter(window, GLFW_TRUE); } + else + { + if (window->wl.fallback.decorations) + window->wl.fallback.focus = surface; + } } static void pointerHandleLeave(void* userData, @@ -1332,6 +1325,11 @@ static void pointerHandleLeave(void* userData, window->wl.hovered = GLFW_FALSE; _glfwInputCursorEnter(window, GLFW_FALSE); } + else + { + if (window->wl.fallback.decorations) + window->wl.fallback.focus = NULL; + } } static void pointerHandleMotion(void* userData, @@ -1363,36 +1361,35 @@ static void pointerHandleMotion(void* userData, { const char* cursorName = NULL; - switch (window->wl.fallback.focus) + if (window->wl.fallback.focus == window->wl.fallback.top.surface) { - case GLFW_TOP_DECORATION: - if (ypos < GLFW_BORDER_SIZE) - cursorName = "n-resize"; - else - cursorName = "left_ptr"; - break; - case GLFW_LEFT_DECORATION: - if (ypos < GLFW_BORDER_SIZE) - cursorName = "nw-resize"; - else - cursorName = "w-resize"; - break; - case GLFW_RIGHT_DECORATION: - if (ypos < GLFW_BORDER_SIZE) - cursorName = "ne-resize"; - else - cursorName = "e-resize"; - break; - case GLFW_BOTTOM_DECORATION: - if (xpos < GLFW_BORDER_SIZE) - cursorName = "sw-resize"; - else if (xpos > window->wl.width + GLFW_BORDER_SIZE) - cursorName = "se-resize"; - else - cursorName = "s-resize"; - break; - default: - assert(0); + if (ypos < GLFW_BORDER_SIZE) + cursorName = "n-resize"; + else + cursorName = "left_ptr"; + } + else if (window->wl.fallback.focus == window->wl.fallback.left.surface) + { + if (ypos < GLFW_BORDER_SIZE) + cursorName = "nw-resize"; + else + cursorName = "w-resize"; + } + else if (window->wl.fallback.focus == window->wl.fallback.right.surface) + { + if (ypos < GLFW_BORDER_SIZE) + cursorName = "ne-resize"; + else + cursorName = "e-resize"; + } + else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface) + { + if (xpos < GLFW_BORDER_SIZE) + cursorName = "sw-resize"; + else if (xpos > window->wl.width + GLFW_BORDER_SIZE) + cursorName = "se-resize"; + else + cursorName = "s-resize"; } if (_glfw.wl.cursorPreviousName != cursorName) @@ -1464,35 +1461,37 @@ static void pointerHandleButton(void* userData, { uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; - switch (window->wl.fallback.focus) + if (window->wl.fallback.focus == window->wl.fallback.top.surface) { - case GLFW_TOP_DECORATION: - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; - else - xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); - break; - case GLFW_LEFT_DECORATION: - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; - break; - case GLFW_RIGHT_DECORATION: - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; - break; - case GLFW_BOTTOM_DECORATION: - if (window->wl.cursorPosX < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; - else if (window->wl.cursorPosX > window->wl.width + GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; - else - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; - break; + if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP; + else + xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); } + else if (window->wl.fallback.focus == window->wl.fallback.left.surface) + { + if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT; + } + else if (window->wl.fallback.focus == window->wl.fallback.right.surface) + { + if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT; + } + else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface) + { + if (window->wl.cursorPosX < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; + else if (window->wl.cursorPosX > window->wl.width + GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; + else + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; + } + if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) { xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, From e25c1cc74f79a49a98edc059c39b76f6577d4dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 8 Feb 2024 00:39:13 +0100 Subject: [PATCH 058/137] Wayland: Make fallback concepts more distinct --- src/wl_platform.h | 6 +-- src/wl_window.c | 98 +++++++++++++++++++++++------------------------ 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index 0d5d3dfd..37adcfd1 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -323,12 +323,12 @@ typedef void (* PFN_libdecor_state_free)(struct libdecor_state*); #define libdecor_state_new _glfw.wl.libdecor.libdecor_state_new_ #define libdecor_state_free _glfw.wl.libdecor.libdecor_state_free_ -typedef struct _GLFWdecorationWayland +typedef struct _GLFWfallbackEdgeWayland { struct wl_surface* surface; struct wl_subsurface* subsurface; struct wp_viewport* viewport; -} _GLFWdecorationWayland; +} _GLFWfallbackEdgeWayland; typedef struct _GLFWofferWayland { @@ -404,7 +404,7 @@ typedef struct _GLFWwindowWayland struct { GLFWbool decorations; struct wl_buffer* buffer; - _GLFWdecorationWayland top, left, right, bottom; + _GLFWfallbackEdgeWayland top, left, right, bottom; struct wl_surface* focus; } fallback; } _GLFWwindowWayland; diff --git a/src/wl_window.c b/src/wl_window.c index 4071b4a5..995c17a6 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -192,29 +192,28 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) return buffer; } -static void createFallbackDecoration(_GLFWwindow* window, - _GLFWdecorationWayland* decoration, - struct wl_surface* parent, - struct wl_buffer* buffer, - int x, int y, - int width, int height) +static void createFallbackEdge(_GLFWwindow* window, + _GLFWfallbackEdgeWayland* edge, + struct wl_surface* parent, + struct wl_buffer* buffer, + int x, int y, + int width, int height) { - decoration->surface = wl_compositor_create_surface(_glfw.wl.compositor); - wl_surface_set_user_data(decoration->surface, window); - wl_proxy_set_tag((struct wl_proxy*) decoration->surface, &_glfw.wl.tag); - decoration->subsurface = - wl_subcompositor_get_subsurface(_glfw.wl.subcompositor, - decoration->surface, parent); - wl_subsurface_set_position(decoration->subsurface, x, y); - decoration->viewport = wp_viewporter_get_viewport(_glfw.wl.viewporter, - decoration->surface); - wp_viewport_set_destination(decoration->viewport, width, height); - wl_surface_attach(decoration->surface, buffer, 0, 0); + edge->surface = wl_compositor_create_surface(_glfw.wl.compositor); + wl_surface_set_user_data(edge->surface, window); + wl_proxy_set_tag((struct wl_proxy*) edge->surface, &_glfw.wl.tag); + edge->subsurface = wl_subcompositor_get_subsurface(_glfw.wl.subcompositor, + edge->surface, parent); + wl_subsurface_set_position(edge->subsurface, x, y); + edge->viewport = wp_viewporter_get_viewport(_glfw.wl.viewporter, + edge->surface); + wp_viewport_set_destination(edge->viewport, width, height); + wl_surface_attach(edge->surface, buffer, 0, 0); struct wl_region* region = wl_compositor_create_region(_glfw.wl.compositor); wl_region_add(region, 0, 0, width, height); - wl_surface_set_opaque_region(decoration->surface, region); - wl_surface_commit(decoration->surface); + wl_surface_set_opaque_region(edge->surface, region); + wl_surface_commit(edge->surface); wl_region_destroy(region); } @@ -231,47 +230,48 @@ static void createFallbackDecorations(_GLFWwindow* window) if (!window->wl.fallback.buffer) return; - createFallbackDecoration(window, &window->wl.fallback.top, window->wl.surface, - window->wl.fallback.buffer, - 0, -GLFW_CAPTION_HEIGHT, - window->wl.width, GLFW_CAPTION_HEIGHT); - createFallbackDecoration(window, &window->wl.fallback.left, window->wl.surface, - window->wl.fallback.buffer, - -GLFW_BORDER_SIZE, -GLFW_CAPTION_HEIGHT, - GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - createFallbackDecoration(window, &window->wl.fallback.right, window->wl.surface, - window->wl.fallback.buffer, - window->wl.width, -GLFW_CAPTION_HEIGHT, - GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); - createFallbackDecoration(window, &window->wl.fallback.bottom, window->wl.surface, - window->wl.fallback.buffer, - -GLFW_BORDER_SIZE, window->wl.height, - window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE); + createFallbackEdge(window, &window->wl.fallback.top, window->wl.surface, + window->wl.fallback.buffer, + 0, -GLFW_CAPTION_HEIGHT, + window->wl.width, GLFW_CAPTION_HEIGHT); + createFallbackEdge(window, &window->wl.fallback.left, window->wl.surface, + window->wl.fallback.buffer, + -GLFW_BORDER_SIZE, -GLFW_CAPTION_HEIGHT, + GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); + createFallbackEdge(window, &window->wl.fallback.right, window->wl.surface, + window->wl.fallback.buffer, + window->wl.width, -GLFW_CAPTION_HEIGHT, + GLFW_BORDER_SIZE, window->wl.height + GLFW_CAPTION_HEIGHT); + createFallbackEdge(window, &window->wl.fallback.bottom, window->wl.surface, + window->wl.fallback.buffer, + -GLFW_BORDER_SIZE, window->wl.height, + window->wl.width + GLFW_BORDER_SIZE * 2, GLFW_BORDER_SIZE); window->wl.fallback.decorations = GLFW_TRUE; } -static void destroyFallbackDecoration(_GLFWdecorationWayland* decoration) +static void destroyFallbackEdge(_GLFWfallbackEdgeWayland* edge) { - if (decoration->subsurface) - wl_subsurface_destroy(decoration->subsurface); - if (decoration->surface) - wl_surface_destroy(decoration->surface); - if (decoration->viewport) - wp_viewport_destroy(decoration->viewport); - decoration->surface = NULL; - decoration->subsurface = NULL; - decoration->viewport = NULL; + if (edge->subsurface) + wl_subsurface_destroy(edge->subsurface); + if (edge->surface) + wl_surface_destroy(edge->surface); + if (edge->viewport) + wp_viewport_destroy(edge->viewport); + + edge->surface = NULL; + edge->subsurface = NULL; + edge->viewport = NULL; } static void destroyFallbackDecorations(_GLFWwindow* window) { window->wl.fallback.decorations = GLFW_FALSE; - destroyFallbackDecoration(&window->wl.fallback.top); - destroyFallbackDecoration(&window->wl.fallback.left); - destroyFallbackDecoration(&window->wl.fallback.right); - destroyFallbackDecoration(&window->wl.fallback.bottom); + destroyFallbackEdge(&window->wl.fallback.top); + destroyFallbackEdge(&window->wl.fallback.left); + destroyFallbackEdge(&window->wl.fallback.right); + destroyFallbackEdge(&window->wl.fallback.bottom); } static void xdgDecorationHandleConfigure(void* userData, From 4c283e4a3c95e09659bf747c7624d075f3110f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 8 Feb 2024 18:55:52 +0100 Subject: [PATCH 059/137] Wayland: Be more specific about scales We are about to introduce another scaling method (fractional-scale-v1), so it will become more important to be specific about what scales are used where and what their units are. This removes 'content scale' from window and monitor structs. A monitor (output) now has just a 'scale', which becomes a 'buffer scale' when applied to a window. A window now has a list of 'output scales' to select its buffer scale from. Content scales are calculated from the respective monitor or window when queried, even if the calculation right now is to just return the same value as before. --- src/wl_monitor.c | 16 ++++++------- src/wl_platform.h | 12 +++++----- src/wl_window.c | 57 ++++++++++++++++++++++++----------------------- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 96527a48..56ea56d7 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -112,16 +112,16 @@ static void outputHandleScale(void* userData, { struct _GLFWmonitor* monitor = userData; - monitor->wl.contentScale = factor; + monitor->wl.scale = factor; for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) { - for (int i = 0; i < window->wl.scaleCount; i++) + for (int i = 0; i < window->wl.outputScaleCount; i++) { - if (window->wl.scales[i].output == monitor->wl.output) + if (window->wl.outputScales[i].output == monitor->wl.output) { - window->wl.scales[i].factor = monitor->wl.contentScale; - _glfwUpdateContentScaleWayland(window); + window->wl.outputScales[i].factor = monitor->wl.scale; + _glfwUpdateBufferScaleFromOutputsWayland(window); break; } } @@ -176,7 +176,7 @@ void _glfwAddOutputWayland(uint32_t name, uint32_t version) // The actual name of this output will be set in the geometry handler _GLFWmonitor* monitor = _glfwAllocMonitor("", 0, 0); - monitor->wl.contentScale = 1; + monitor->wl.scale = 1; monitor->wl.output = output; monitor->wl.name = name; @@ -207,9 +207,9 @@ void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale) { if (xscale) - *xscale = (float) monitor->wl.contentScale; + *xscale = (float) monitor->wl.scale; if (yscale) - *yscale = (float) monitor->wl.contentScale; + *yscale = (float) monitor->wl.scale; } void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, diff --git a/src/wl_platform.h b/src/wl_platform.h index 37adcfd1..23fd8c14 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -389,10 +389,10 @@ typedef struct _GLFWwindowWayland // We need to track the monitors the window spans on to calculate the // optimal scaling factor. - int contentScale; - _GLFWscaleWayland* scales; - int scaleCount; - int scaleSize; + int bufferScale; + _GLFWscaleWayland* outputScales; + int outputScaleCount; + int outputScaleSize; struct zwp_relative_pointer_v1* relativePointer; struct zwp_locked_pointer_v1* lockedPointer; @@ -586,7 +586,7 @@ typedef struct _GLFWmonitorWayland int x; int y; - int contentScale; + int scale; } _GLFWmonitorWayland; // Wayland-specific per-cursor data @@ -677,7 +677,7 @@ GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); void _glfwAddOutputWayland(uint32_t name, uint32_t version); -void _glfwUpdateContentScaleWayland(_GLFWwindow* window); +void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window); void _glfwAddSeatListenerWayland(struct wl_seat* seat); void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device); diff --git a/src/wl_window.c b/src/wl_window.c index 995c17a6..e5699ab3 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -312,7 +312,7 @@ static void setContentAreaOpaque(_GLFWwindow* window) static void resizeFramebuffer(_GLFWwindow* window) { - int scale = window->wl.contentScale; + int scale = window->wl.bufferScale; int scaledWidth = window->wl.width * scale; int scaledHeight = window->wl.height * scale; @@ -357,7 +357,7 @@ static void resizeWindow(_GLFWwindow* window) } } -void _glfwUpdateContentScaleWayland(_GLFWwindow* window) +void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window) { if (wl_compositor_get_version(_glfw.wl.compositor) < WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION) @@ -368,13 +368,13 @@ void _glfwUpdateContentScaleWayland(_GLFWwindow* window) // Get the scale factor from the highest scale monitor. int maxScale = 1; - for (int i = 0; i < window->wl.scaleCount; i++) - maxScale = _glfw_max(window->wl.scales[i].factor, maxScale); + for (int i = 0; i < window->wl.outputScaleCount; i++) + maxScale = _glfw_max(window->wl.outputScales[i].factor, maxScale); // Only change the framebuffer size if the scale changed. - if (window->wl.contentScale != maxScale) + if (window->wl.bufferScale != maxScale) { - window->wl.contentScale = maxScale; + window->wl.bufferScale = maxScale; wl_surface_set_buffer_scale(window->wl.surface, maxScale); _glfwInputWindowContentScale(window, maxScale, maxScale); resizeFramebuffer(window); @@ -396,19 +396,19 @@ static void surfaceHandleEnter(void* userData, if (!window || !monitor) return; - if (window->wl.scaleCount + 1 > window->wl.scaleSize) + if (window->wl.outputScaleCount + 1 > window->wl.outputScaleSize) { - window->wl.scaleSize++; - window->wl.scales = - _glfw_realloc(window->wl.scales, - window->wl.scaleSize * sizeof(_GLFWscaleWayland)); + window->wl.outputScaleSize++; + window->wl.outputScales = + _glfw_realloc(window->wl.outputScales, + window->wl.outputScaleSize * sizeof(_GLFWscaleWayland)); } - window->wl.scaleCount++; - window->wl.scales[window->wl.scaleCount - 1].factor = monitor->wl.contentScale; - window->wl.scales[window->wl.scaleCount - 1].output = output; + window->wl.outputScaleCount++; + window->wl.outputScales[window->wl.outputScaleCount - 1] = + (_GLFWscaleWayland) { output, monitor->wl.scale }; - _glfwUpdateContentScaleWayland(window); + _glfwUpdateBufferScaleFromOutputsWayland(window); } static void surfaceHandleLeave(void* userData, @@ -420,17 +420,18 @@ static void surfaceHandleLeave(void* userData, _GLFWwindow* window = userData; - for (int i = 0; i < window->wl.scaleCount; i++) + for (int i = 0; i < window->wl.outputScaleCount; i++) { - if (window->wl.scales[i].output == output) + if (window->wl.outputScales[i].output == output) { - window->wl.scales[i] = window->wl.scales[window->wl.scaleCount - 1]; - window->wl.scaleCount--; + window->wl.outputScales[i] = + window->wl.outputScales[window->wl.outputScaleCount - 1]; + window->wl.outputScaleCount--; break; } } - _glfwUpdateContentScaleWayland(window); + _glfwUpdateBufferScaleFromOutputsWayland(window); } static const struct wl_surface_listener surfaceListener = @@ -970,7 +971,7 @@ static GLFWbool createNativeSurface(_GLFWwindow* window, window->wl.width = wndconfig->width; window->wl.height = wndconfig->height; - window->wl.contentScale = 1; + window->wl.bufferScale = 1; window->wl.title = _glfw_strdup(wndconfig->title); window->wl.appId = _glfw_strdup(wndconfig->wl.appId); @@ -997,7 +998,7 @@ static void setCursorImage(_GLFWwindow* window, buffer = cursorWayland->buffer; else { - if (window->wl.contentScale > 1 && cursorWayland->cursorHiDPI) + if (window->wl.bufferScale > 1 && cursorWayland->cursorHiDPI) { wlCursor = cursorWayland->cursorHiDPI; scale = 2; @@ -1398,7 +1399,7 @@ static void pointerHandleMotion(void* userData, struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; int scale = 1; - if (window->wl.contentScale > 1 && _glfw.wl.cursorThemeHiDPI) + if (window->wl.bufferScale > 1 && _glfw.wl.cursorThemeHiDPI) { // We only support up to scale=2 for now, since libwayland-cursor // requires us to load a different theme for each size. @@ -2120,7 +2121,7 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) _glfw_free(window->wl.title); _glfw_free(window->wl.appId); - _glfw_free(window->wl.scales); + _glfw_free(window->wl.outputScales); } void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title) @@ -2279,9 +2280,9 @@ void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height { _glfwGetWindowSizeWayland(window, width, height); if (width) - *width *= window->wl.contentScale; + *width *= window->wl.bufferScale; if (height) - *height *= window->wl.contentScale; + *height *= window->wl.bufferScale; } void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, @@ -2305,9 +2306,9 @@ void _glfwGetWindowContentScaleWayland(_GLFWwindow* window, float* xscale, float* yscale) { if (xscale) - *xscale = (float) window->wl.contentScale; + *xscale = (float) window->wl.bufferScale; if (yscale) - *yscale = (float) window->wl.contentScale; + *yscale = (float) window->wl.bufferScale; } void _glfwIconifyWindowWayland(_GLFWwindow* window) From 1be7bc546b41efcab84210f15ddb7cdf25171cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 8 Feb 2024 19:36:27 +0100 Subject: [PATCH 060/137] Wayland: Clean up data types related to scales --- src/wl_monitor.c | 2 +- src/wl_platform.h | 10 +++++----- src/wl_window.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 56ea56d7..66639301 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -116,7 +116,7 @@ static void outputHandleScale(void* userData, for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) { - for (int i = 0; i < window->wl.outputScaleCount; i++) + for (size_t i = 0; i < window->wl.outputScaleCount; i++) { if (window->wl.outputScales[i].output == monitor->wl.output) { diff --git a/src/wl_platform.h b/src/wl_platform.h index 23fd8c14..d54d394a 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -340,7 +340,7 @@ typedef struct _GLFWofferWayland typedef struct _GLFWscaleWayland { struct wl_output* output; - int factor; + int32_t factor; } _GLFWscaleWayland; // Wayland-specific per-window data @@ -389,10 +389,10 @@ typedef struct _GLFWwindowWayland // We need to track the monitors the window spans on to calculate the // optimal scaling factor. - int bufferScale; + int32_t bufferScale; _GLFWscaleWayland* outputScales; - int outputScaleCount; - int outputScaleSize; + size_t outputScaleCount; + size_t outputScaleSize; struct zwp_relative_pointer_v1* relativePointer; struct zwp_locked_pointer_v1* lockedPointer; @@ -586,7 +586,7 @@ typedef struct _GLFWmonitorWayland int x; int y; - int scale; + int32_t scale; } _GLFWmonitorWayland; // Wayland-specific per-cursor data diff --git a/src/wl_window.c b/src/wl_window.c index e5699ab3..71be06b7 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -312,7 +312,7 @@ static void setContentAreaOpaque(_GLFWwindow* window) static void resizeFramebuffer(_GLFWwindow* window) { - int scale = window->wl.bufferScale; + int32_t scale = window->wl.bufferScale; int scaledWidth = window->wl.width * scale; int scaledHeight = window->wl.height * scale; @@ -366,9 +366,9 @@ void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window) } // Get the scale factor from the highest scale monitor. - int maxScale = 1; + int32_t maxScale = 1; - for (int i = 0; i < window->wl.outputScaleCount; i++) + for (size_t i = 0; i < window->wl.outputScaleCount; i++) maxScale = _glfw_max(window->wl.outputScales[i].factor, maxScale); // Only change the framebuffer size if the scale changed. @@ -420,7 +420,7 @@ static void surfaceHandleLeave(void* userData, _GLFWwindow* window = userData; - for (int i = 0; i < window->wl.outputScaleCount; i++) + for (size_t i = 0; i < window->wl.outputScaleCount; i++) { if (window->wl.outputScales[i].output == output) { From 9953f7ead17011ccc4f747291ef48de8d2ed7184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 8 Feb 2024 22:07:11 +0100 Subject: [PATCH 061/137] Wayland: Cache framebuffer size The calculation of framebuffer size is about to get more complicated with the introduction of fractional-scale-v1, so only do it in one place. This is also a tiny preparation for eventually behaving better towards wl_egl_window_resize. --- src/wl_platform.h | 1 + src/wl_window.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index d54d394a..b1303d9f 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -348,6 +348,7 @@ typedef struct _GLFWscaleWayland typedef struct _GLFWwindowWayland { int width, height; + int fbWidth, fbHeight; GLFWbool visible; GLFWbool maximized; GLFWbool activated; diff --git a/src/wl_window.c b/src/wl_window.c index 71be06b7..13879a12 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -312,17 +312,21 @@ static void setContentAreaOpaque(_GLFWwindow* window) static void resizeFramebuffer(_GLFWwindow* window) { - int32_t scale = window->wl.bufferScale; - int scaledWidth = window->wl.width * scale; - int scaledHeight = window->wl.height * scale; + window->wl.fbWidth = window->wl.width * window->wl.bufferScale; + window->wl.fbHeight = window->wl.height * window->wl.bufferScale; if (window->wl.egl.window) - wl_egl_window_resize(window->wl.egl.window, scaledWidth, scaledHeight, 0, 0); + { + wl_egl_window_resize(window->wl.egl.window, + window->wl.fbWidth, + window->wl.fbHeight, + 0, 0); + } if (!window->wl.transparent) setContentAreaOpaque(window); - _glfwInputFramebufferSize(window, scaledWidth, scaledHeight); + _glfwInputFramebufferSize(window, window->wl.fbWidth, window->wl.fbHeight); } static void resizeWindow(_GLFWwindow* window) @@ -971,6 +975,8 @@ static GLFWbool createNativeSurface(_GLFWwindow* window, window->wl.width = wndconfig->width; window->wl.height = wndconfig->height; + window->wl.fbWidth = wndconfig->width; + window->wl.fbHeight = wndconfig->height; window->wl.bufferScale = 1; window->wl.title = _glfw_strdup(wndconfig->title); window->wl.appId = _glfw_strdup(wndconfig->wl.appId); @@ -2044,8 +2050,8 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, ctxconfig->source == GLFW_NATIVE_CONTEXT_API) { window->wl.egl.window = wl_egl_window_create(window->wl.surface, - wndconfig->width, - wndconfig->height); + window->wl.fbWidth, + window->wl.fbHeight); if (!window->wl.egl.window) { _glfwInputError(GLFW_PLATFORM_ERROR, @@ -2278,11 +2284,10 @@ void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom) void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height) { - _glfwGetWindowSizeWayland(window, width, height); if (width) - *width *= window->wl.bufferScale; + *width = window->wl.fbWidth; if (height) - *height *= window->wl.bufferScale; + *height = window->wl.fbHeight; } void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, From edd38207a67ea7d5c9c784a3304d044ab16fc06a Mon Sep 17 00:00:00 2001 From: Victor Chernyakin <56512186+LocalSpook@users.noreply.github.com> Date: Fri, 15 Dec 2023 00:53:32 -0700 Subject: [PATCH 062/137] Linux: Set O_CLOEXEC on evdev fd Closes #2446 --- src/linux_joystick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/linux_joystick.c b/src/linux_joystick.c index c67f3d77..07d41d37 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -135,7 +135,7 @@ static GLFWbool openJoystickDevice(const char* path) } _GLFWjoystickLinux linjs = {0}; - linjs.fd = open(path, O_RDONLY | O_NONBLOCK); + linjs.fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC); if (linjs.fd == -1) return GLFW_FALSE; From 6565c0cc04837d3b95dc9d552f73f9bfcf8c8e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 9 Feb 2024 14:13:32 +0100 Subject: [PATCH 063/137] Update changelog and add credit Related to #2446 --- CONTRIBUTORS.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 6f426cdd..273d3d49 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -33,6 +33,7 @@ video tutorials. - David Carlier - Arturo Castro - Chi-kwan Chan + - Victor Chernyakin - TheChocolateOre - Ali Chraghi - Joseph Chua diff --git a/README.md b/README.md index 177960f6..3cafbc95 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,7 @@ information on what to include when reporting a bug. fallback window decoration - [X11] Bugfix: Termination would segfault if the IM had been destroyed - [X11] Bugfix: Any IM started after initialization would not be detected + - [Linux] Bugfix: Joystick evdev fds remained open in forks (#2446) - [POSIX] Removed use of deprecated function `gettimeofday` - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) From 6f1ddf51a130f2dee6ade5fa4d8217e4071124e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 11 Feb 2024 12:59:08 +0100 Subject: [PATCH 064/137] Wayland: Remove unused struct member --- src/wl_platform.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index b1303d9f..3b9a3a3c 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -379,7 +379,6 @@ typedef struct _GLFWwindowWayland struct { struct libdecor_frame* frame; - int mode; } libdecor; _GLFWcursor* currentCursor; From 30127690a2c8a781440ab59b44f623d22e67e909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 2 Feb 2024 14:47:55 +0100 Subject: [PATCH 065/137] Add credit Related to #2445 --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 273d3d49..5f5c12f8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -250,6 +250,7 @@ video tutorials. - Paul Sultana - Nathan Sweet - TTK-Bandit + - Nuno Teixeira - Jared Tiala - Sergey Tikhomirov - Arthur Tombs From 5a0ab56ed79595ee991e51a951f103a1c612b6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 12 Feb 2024 01:08:38 +0100 Subject: [PATCH 066/137] Fix spelling --- docs/news.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/news.dox b/docs/news.dox index 28c500d9..185b962d 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -136,7 +136,7 @@ To work around this, call any joystick function before waiting for events, for example by setting a [joystick callback](@ref joystick_event). -@subsubsection wayland_alpha_34 Frambuffer may lack alpha channel on older Wayland systems +@subsubsection wayland_alpha_34 Framebuffer may lack alpha channel on older Wayland systems On Wayland, when creating an EGL context on a machine lacking the new `EGL_EXT_present_opaque` extension, the @ref GLFW_ALPHA_BITS window hint will be From bb951b4b712b3ebcbb9e07fee48b7ee3247b033a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 12:56:53 +0100 Subject: [PATCH 067/137] Use C99 fminf and fmaxf --- src/init.c | 24 ------------------------ src/input.c | 2 +- src/internal.h | 2 -- src/monitor.c | 2 +- src/null_monitor.c | 2 +- 5 files changed, 3 insertions(+), 29 deletions(-) diff --git a/src/init.c b/src/init.c index 2b903146..532264e1 100644 --- a/src/init.c +++ b/src/init.c @@ -246,30 +246,6 @@ int _glfw_max(int a, int b) return a > b ? a : b; } -float _glfw_fminf(float a, float b) -{ - if (a != a) - return b; - else if (b != b) - return a; - else if (a < b) - return a; - else - return b; -} - -float _glfw_fmaxf(float a, float b) -{ - if (a != a) - return b; - else if (b != b) - return a; - else if (a > b) - return a; - else - return b; -} - void* _glfw_calloc(size_t count, size_t size) { if (count && size) diff --git a/src/input.c b/src/input.c index 542fabe3..7b3b3402 100644 --- a/src/input.c +++ b/src/input.c @@ -1438,7 +1438,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state) if (e->type == _GLFW_JOYSTICK_AXIS) { const float value = js->axes[e->index] * e->axisScale + e->axisOffset; - state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f); + state->axes[i] = fminf(fmaxf(value, -1.f), 1.f); } else if (e->type == _GLFW_JOYSTICK_HATBIT) { diff --git a/src/internal.h b/src/internal.h index 1ab3dea8..aec9eb77 100644 --- a/src/internal.h +++ b/src/internal.h @@ -997,8 +997,6 @@ char** _glfwParseUriList(char* text, int* count); char* _glfw_strdup(const char* source); int _glfw_min(int a, int b); int _glfw_max(int a, int b); -float _glfw_fminf(float a, float b); -float _glfw_fmaxf(float a, float b); void* _glfw_calloc(size_t count, size_t size); void* _glfw_realloc(void* pointer, size_t size); diff --git a/src/monitor.c b/src/monitor.c index 61cdcb8f..b76ac6db 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -487,7 +487,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) // Apply gamma curve value = powf(value, 1.f / gamma) * 65535.f + 0.5f; // Clamp to value range - value = _glfw_fminf(value, 65535.f); + value = fminf(value, 65535.f); values[i] = (unsigned short) value; } diff --git a/src/null_monitor.c b/src/null_monitor.c index 787fde71..63cd462f 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -128,7 +128,7 @@ GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp) 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); + value = fminf(value, 65535.f); monitor->null.ramp.red[i] = (unsigned short) value; monitor->null.ramp.green[i] = (unsigned short) value; From a12311e596a3bca3b41388b5de5b566374dc9841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 31 Jan 2024 00:49:53 +0100 Subject: [PATCH 068/137] Document GLFW_FLOATING not supported on Wayland --- include/GLFW/glfw3.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 6f8c9b41..f86b176c 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -4041,11 +4041,14 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR and @ref - * GLFW_FEATURE_UNAVAILABLE. + * GLFW_FEATURE_UNAVAILABLE (see remarks). * * @remark Calling @ref glfwGetWindowAttrib will always return the latest * value, even if that value is ignored by the current mode of the window. * + * @remark @wayland The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window attribute is + * not supported. Setting this will emit @ref GLFW_FEATURE_UNAVAILABLE. + * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_attribs From 2afd57bf9b371f30bf654d9fefff6bd39b981933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 31 Jan 2024 01:45:02 +0100 Subject: [PATCH 069/137] Expand documentation for custom allocator Fixes #2298 --- docs/intro.dox | 15 ++++++-- include/GLFW/glfw3.h | 87 +++++++++++++++++++++++++++++++++----------- 2 files changed, 78 insertions(+), 24 deletions(-) diff --git a/docs/intro.dox b/docs/intro.dox index 36ec0ef5..bfb3ddcd 100644 --- a/docs/intro.dox +++ b/docs/intro.dox @@ -223,9 +223,9 @@ allocator.user = NULL; glfwInitAllocator(&allocator); @endcode -The allocator will be picked up at the beginning of initialization and will be -used until GLFW has been fully terminated. Any allocator set after -initialization will be picked up only at the next initialization. +The allocator will be made active at the beginning of initialization and will be used by +GLFW until the library has been fully terminated. Any allocator set after initialization +will be picked up only at the next initialization. The allocator will only be used for allocations that would have been made with the C standard library. Memory allocations that must be made with platform @@ -242,6 +242,9 @@ void* my_malloc(size_t size, void* user) } @endcode +The documentation for @ref GLFWallocatefun also lists the requirements and limitations for +an allocation function. If the active one does not meet all of these, GLFW may fail. + The reallocation function must have a function signature matching @ref GLFWreallocatefun. It receives the memory block to be reallocated, the new desired size, in bytes, and the user pointer passed to @ref glfwInitAllocator and returns the address to the resized memory @@ -254,6 +257,9 @@ void* my_realloc(void* block, size_t size, void* user) } @endcode +The documentation for @ref GLFWreallocatefun also lists the requirements and limitations +for a reallocation function. If the active one does not meet all of these, GLFW may fail. + The deallocation function must have a function signature matching @ref GLFWdeallocatefun. It receives the memory block to be deallocated and the user pointer passed to @ref glfwInitAllocator. @@ -265,6 +271,9 @@ void my_free(void* block, void* user) } @endcode +The documentation for @ref GLFWdeallocatefun also lists the requirements and limitations +for a deallocation function. If the active one does not meet all of these, GLFW may fail. + @subsection intro_init_terminate Terminating GLFW diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index f86b176c..aafd1621 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1416,16 +1416,25 @@ typedef struct GLFWcursor GLFWcursor; * or `NULL` if allocation failed. Note that not all parts of GLFW handle allocation * failures gracefully yet. * - * This function may be called during @ref glfwInit but before the library is - * flagged as initialized, as well as during @ref glfwTerminate after the - * library is no longer flagged as initialized. + * This function must support being called during @ref glfwInit but before the library is + * flagged as initialized, as well as during @ref glfwTerminate after the library is no + * longer flagged as initialized. * - * Any memory allocated by this function will be deallocated during library - * termination or earlier. + * Any memory allocated via this function will be deallocated via the same allocator + * during library termination or earlier. + * + * Any memory allocated via this function must be suitably aligned for any object type. + * If you are using C99 or earlier, this alignment is platform-dependent but will be the + * same as what `malloc` provides. If you are using C11 or later, this is the value of + * `alignof(max_align_t)`. * * The size will always be greater than zero. Allocations of size zero are filtered out * before reaching the custom allocator. * + * If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY. + * + * This function must not call any GLFW function. + * * @param[in] size The minimum size, in bytes, of the memory block. * @param[in] user The user-defined pointer from the allocator. * @return The address of the newly allocated memory block, or `NULL` if an @@ -1436,7 +1445,8 @@ typedef struct GLFWcursor GLFWcursor; * * @reentrancy This function should not call any GLFW function. * - * @thread_safety This function may be called from any thread that calls GLFW functions. + * @thread_safety This function must support being called from any thread that calls GLFW + * functions. * * @sa @ref init_allocator * @sa @ref GLFWallocator @@ -1459,16 +1469,26 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user); * `NULL` if allocation failed. Note that not all parts of GLFW handle allocation * failures gracefully yet. * - * This function may be called during @ref glfwInit but before the library is - * flagged as initialized, as well as during @ref glfwTerminate after the - * library is no longer flagged as initialized. + * This function must support being called during @ref glfwInit but before the library is + * flagged as initialized, as well as during @ref glfwTerminate after the library is no + * longer flagged as initialized. * - * Any memory allocated by this function will be deallocated during library - * termination or earlier. + * Any memory allocated via this function will be deallocated via the same allocator + * during library termination or earlier. + * + * Any memory allocated via this function must be suitably aligned for any object type. + * If you are using C99 or earlier, this alignment is platform-dependent but will be the + * same as what `realloc` provides. If you are using C11 or later, this is the value of + * `alignof(max_align_t)`. * * The block address will never be `NULL` and the size will always be greater than zero. - * Reallocations of a block to size zero are converted into deallocations. Reallocations - * of `NULL` to a non-zero size are converted into regular allocations. + * Reallocations of a block to size zero are converted into deallocations before reaching + * the custom allocator. Reallocations of `NULL` to a non-zero size are converted into + * regular allocations before reaching the custom allocator. + * + * If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY. + * + * This function must not call any GLFW function. * * @param[in] block The address of the memory block to reallocate. * @param[in] size The new minimum size, in bytes, of the memory block. @@ -1481,7 +1501,8 @@ typedef void* (* GLFWallocatefun)(size_t size, void* user); * * @reentrancy This function should not call any GLFW function. * - * @thread_safety This function may be called from any thread that calls GLFW functions. + * @thread_safety This function must support being called from any thread that calls GLFW + * functions. * * @sa @ref init_allocator * @sa @ref GLFWallocator @@ -1503,13 +1524,17 @@ typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user); * This function may deallocate the specified memory block. This memory block * will have been allocated with the same allocator. * - * This function may be called during @ref glfwInit but before the library is - * flagged as initialized, as well as during @ref glfwTerminate after the - * library is no longer flagged as initialized. + * This function must support being called during @ref glfwInit but before the library is + * flagged as initialized, as well as during @ref glfwTerminate after the library is no + * longer flagged as initialized. * * The block address will never be `NULL`. Deallocations of `NULL` are filtered out * before reaching the custom allocator. * + * If this function returns `NULL`, GLFW will emit @ref GLFW_OUT_OF_MEMORY. + * + * This function must not call any GLFW function. + * * @param[in] block The address of the memory block to deallocate. * @param[in] user The user-defined pointer from the allocator. * @@ -1518,7 +1543,8 @@ typedef void* (* GLFWreallocatefun)(void* block, size_t size, void* user); * * @reentrancy This function should not call any GLFW function. * - * @thread_safety This function may be called from any thread that calls GLFW functions. + * @thread_safety This function must support being called from any thread that calls GLFW + * functions. * * @sa @ref init_allocator * @sa @ref GLFWallocator @@ -2086,7 +2112,10 @@ typedef struct GLFWgamepadstate float axes[6]; } GLFWgamepadstate; -/*! @brief +/*! @brief Custom heap memory allocator. + * + * This describes a custom heap memory allocator for GLFW. To set an allocator, pass it + * to @ref glfwInitAllocator before initializing the library. * * @sa @ref init_allocator * @sa @ref glfwInitAllocator @@ -2097,9 +2126,21 @@ typedef struct GLFWgamepadstate */ typedef struct GLFWallocator { + /*! The memory allocation function. See @ref GLFWallocatefun for details about + * allocation function. + */ GLFWallocatefun allocate; + /*! The memory reallocation function. See @ref GLFWreallocatefun for details about + * reallocation function. + */ GLFWreallocatefun reallocate; + /*! The memory deallocation function. See @ref GLFWdeallocatefun for details about + * deallocation function. + */ GLFWdeallocatefun deallocate; + /*! The user pointer for this custom allocator. This value will be passed to the + * allocator functions. + */ void* user; } GLFWallocator; @@ -2232,8 +2273,12 @@ GLFWAPI void glfwInitHint(int hint, int value); * To use the default allocator, call this function with a `NULL` argument. * * If you specify an allocator struct, every member must be a valid function - * pointer. If any member is `NULL`, this function emits @ref - * GLFW_INVALID_VALUE and the init allocator is unchanged. + * pointer. If any member is `NULL`, this function will emit @ref + * GLFW_INVALID_VALUE and the init allocator will be unchanged. + * + * The functions in the allocator must fulfil a number of requirements. See the + * documentation for @ref GLFWallocatefun, @ref GLFWreallocatefun and @ref + * GLFWdeallocatefun for details. * * @param[in] allocator The allocator to use at the next initialization, or * `NULL` to use the default one. From 8946f5314dbe4fcb84a48e2fc554a129b6d2c361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 1 Feb 2024 02:10:34 +0100 Subject: [PATCH 070/137] Win32: Add GLFW_WIN32_SHOWDEFAULT Fixes #2359 --- README.md | 2 ++ docs/news.dox | 8 ++++++++ docs/window.dox | 9 +++++++++ include/GLFW/glfw3.h | 3 +++ src/internal.h | 1 + src/win32_platform.h | 1 + src/win32_window.c | 19 ++++++++++++++++++- src/window.c | 3 +++ 8 files changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cafbc95..b7758557 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,8 @@ information on what to include when reporting a bug. - Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan surface extension (#1793) - Added `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu + - Added `GLFW_WIN32_SHOWDEFAULT` window hint for applying the parent process + show command (#2359) - Added `GLFW_NATIVE_INCLUDE_NONE` for disabling inclusion of native headers (#1348) - Added `GLFW_BUILD_WIN32` CMake option for enabling Win32 support (#1958) - Added `GLFW_BUILD_COCOA` CMake option for enabling Cocoa support (#1958) diff --git a/docs/news.dox b/docs/news.dox index 185b962d..2a546bc6 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -103,6 +103,13 @@ Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented applications. +@subsubsection features_34_win32_showdefault Support for applying STARTUPINFO show command + +GLFW now provides the [GLFW_WIN32_SHOWDEFAULT](@ref GLFW_WIN32_SHOWDEFAULT_hint) window +hint for applying the show command in the program's `STARTUPINFO` when showing the window +for the first time. This may be useful for the main window of a windowed-mode tool. + + @subsection caveats Caveats for version 3.4 @subsubsection native_34 Multiple sets of native access functions @@ -261,6 +268,7 @@ then GLFW will fail to initialize. - @ref GLFW_NOT_ALLOWED_CURSOR - @ref GLFW_CURSOR_UNAVAILABLE - @ref GLFW_WIN32_KEYBOARD_MENU + - @ref GLFW_WIN32_SHOWDEFAULT - @ref GLFW_CONTEXT_DEBUG - @ref GLFW_FEATURE_UNAVAILABLE - @ref GLFW_FEATURE_UNIMPLEMENTED diff --git a/docs/window.dox b/docs/window.dox index 3cec6358..568c388f 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -462,6 +462,14 @@ __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. +@anchor GLFW_WIN32_SHOWDEFAULT_hint +__GLFW_WIN32_SHOWDEFAULT__ specifies whether to show the window the way +specified in the program's `STARTUPINFO` when it is shown for the first time. +This is the same information as the `Run` option in the shortcut properties +window. If this information was not specified when the program was started, +GLFW behaves as if this hint was set to `GLFW_FALSE`. Possible values are +`GLFW_TRUE` and `GLFW_FALSE`. This is ignored on other platforms. + @subsubsection window_hints_osx macOS specific hints @@ -553,6 +561,7 @@ GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GL GLFW_CONTEXT_DEBUG | `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_WIN32_SHOWDEFAULT | `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 aafd1621..d40126ae 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1119,6 +1119,9 @@ extern "C" { */ #define GLFW_X11_INSTANCE_NAME 0x00024002 #define GLFW_WIN32_KEYBOARD_MENU 0x00025001 +/*! @brief Win32 specific [window hint](@ref GLFW_WIN32_SHOWDEFAULT_hint). + */ +#define GLFW_WIN32_SHOWDEFAULT 0x00025002 /*! @brief Wayland specific * [window hint](@ref GLFW_WAYLAND_APP_ID_hint). * diff --git a/src/internal.h b/src/internal.h index aec9eb77..caf93675 100644 --- a/src/internal.h +++ b/src/internal.h @@ -412,6 +412,7 @@ struct _GLFWwndconfig } x11; struct { GLFWbool keymenu; + GLFWbool showDefault; } win32; struct { char appId[256]; diff --git a/src/win32_platform.h b/src/win32_platform.h index 1db31584..366674fe 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -424,6 +424,7 @@ typedef struct _GLFWwindowWin32 GLFWbool transparent; GLFWbool scaleToMonitor; GLFWbool keymenu; + GLFWbool showDefault; // Cached size used to filter out duplicate events int width, height; diff --git a/src/win32_window.c b/src/win32_window.c index 917a0f6c..6191f9a4 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1390,6 +1390,7 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.keymenu = wndconfig->win32.keymenu; + window->win32.showDefault = wndconfig->win32.showDefault; if (!window->monitor) { @@ -1772,7 +1773,23 @@ void _glfwMaximizeWindowWin32(_GLFWwindow* window) void _glfwShowWindowWin32(_GLFWwindow* window) { - ShowWindow(window->win32.handle, SW_SHOWNA); + int showCommand = SW_SHOWNA; + + if (window->win32.showDefault) + { + // NOTE: GLFW windows currently do not seem to match the Windows 10 definition of + // a main window, so even SW_SHOWDEFAULT does nothing + // This definition is undocumented and can change (source: Raymond Chen) + // HACK: Apply the STARTUPINFO show command manually if available + STARTUPINFOW si = { sizeof(si) }; + GetStartupInfoW(&si); + if (si.dwFlags & STARTF_USESHOWWINDOW) + showCommand = si.wShowWindow; + + window->win32.showDefault = GLFW_FALSE; + } + + ShowWindow(window->win32.handle, showCommand); } void _glfwHideWindowWin32(_GLFWwindow* window) diff --git a/src/window.c b/src/window.c index 51903e63..0e279336 100644 --- a/src/window.c +++ b/src/window.c @@ -380,6 +380,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_WIN32_KEYBOARD_MENU: _glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE; return; + case GLFW_WIN32_SHOWDEFAULT: + _glfw.hints.window.win32.showDefault = value ? GLFW_TRUE : GLFW_FALSE; + return; case GLFW_COCOA_GRAPHICS_SWITCHING: _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; return; From 77ced84e9ce12d7cb4522e134044a1a4582f4dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 22 Jan 2024 21:19:02 +0100 Subject: [PATCH 071/137] Use C99 instead of hard-coded indices --- src/wl_window.c | 21 +++++++++++---------- src/x11_window.c | 15 ++++++++------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 13879a12..06b0256f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1125,16 +1125,17 @@ static void handleEvents(double* timeout) #endif GLFWbool event = GLFW_FALSE; - struct pollfd fds[4] = + enum { DISPLAY_FD, KEYREPEAT_FD, CURSOR_FD, LIBDECOR_FD }; + struct pollfd fds[] = { - { wl_display_get_fd(_glfw.wl.display), POLLIN }, - { _glfw.wl.keyRepeatTimerfd, POLLIN }, - { _glfw.wl.cursorTimerfd, POLLIN }, - { -1, POLLIN } + [DISPLAY_FD] = { wl_display_get_fd(_glfw.wl.display), POLLIN }, + [KEYREPEAT_FD] = { _glfw.wl.keyRepeatTimerfd, POLLIN }, + [CURSOR_FD] = { _glfw.wl.cursorTimerfd, POLLIN }, + [LIBDECOR_FD] = { -1, POLLIN } }; if (_glfw.wl.libdecor.context) - fds[3].fd = libdecor_get_fd(_glfw.wl.libdecor.context); + fds[LIBDECOR_FD].fd = libdecor_get_fd(_glfw.wl.libdecor.context); while (!event) { @@ -1166,7 +1167,7 @@ static void handleEvents(double* timeout) return; } - if (fds[0].revents & POLLIN) + if (fds[DISPLAY_FD].revents & POLLIN) { wl_display_read_events(_glfw.wl.display); if (wl_display_dispatch_pending(_glfw.wl.display) > 0) @@ -1175,7 +1176,7 @@ static void handleEvents(double* timeout) else wl_display_cancel_read(_glfw.wl.display); - if (fds[1].revents & POLLIN) + if (fds[KEYREPEAT_FD].revents & POLLIN) { uint64_t repeats; @@ -1195,7 +1196,7 @@ static void handleEvents(double* timeout) } } - if (fds[2].revents & POLLIN) + if (fds[CURSOR_FD].revents & POLLIN) { uint64_t repeats; @@ -1203,7 +1204,7 @@ static void handleEvents(double* timeout) incrementCursorImage(_glfw.wl.pointerFocus); } - if (fds[3].revents & POLLIN) + if (fds[LIBDECOR_FD].revents & POLLIN) { if (libdecor_dispatch(_glfw.wl.libdecor.context, 0) > 0) event = GLFW_TRUE; diff --git a/src/x11_window.c b/src/x11_window.c index c2541b9f..a94978cf 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -79,24 +79,25 @@ static GLFWbool waitForX11Event(double* timeout) // static GLFWbool waitForAnyEvent(double* timeout) { - nfds_t count = 2; - struct pollfd fds[3] = + enum { XLIB_FD, PIPE_FD, INOTIFY_FD }; + struct pollfd fds[] = { - { ConnectionNumber(_glfw.x11.display), POLLIN }, - { _glfw.x11.emptyEventPipe[0], POLLIN } + [XLIB_FD] = { ConnectionNumber(_glfw.x11.display), POLLIN }, + [PIPE_FD] = { _glfw.x11.emptyEventPipe[0], POLLIN }, + [INOTIFY_FD] = { -1, POLLIN } }; #if defined(GLFW_BUILD_LINUX_JOYSTICK) if (_glfw.joysticksInitialized) - fds[count++] = (struct pollfd) { _glfw.linjs.inotify, POLLIN }; + fds[INOTIFY_FD].fd = _glfw.linjs.inotify; #endif while (!XPending(_glfw.x11.display)) { - if (!_glfwPollPOSIX(fds, count, timeout)) + if (!_glfwPollPOSIX(fds, sizeof(fds) / sizeof(fds[0]), timeout)) return GLFW_FALSE; - for (int i = 1; i < count; i++) + for (int i = 1; i < sizeof(fds) / sizeof(fds[0]); i++) { if (fds[i].revents & POLLIN) return GLFW_TRUE; From efffd492ddb6a72812b15ee2717a55c1133c2d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 21 Jan 2024 15:35:31 +0100 Subject: [PATCH 072/137] Wayland: Check all xkbcommon entry points --- src/wl_init.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/wl_init.c b/src/wl_init.c index b0e4e45e..2644e89a 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -693,6 +693,32 @@ int _glfwInitWayland(void) _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym"); + if (!_glfw.wl.xkb.context_new || + !_glfw.wl.xkb.context_unref || + !_glfw.wl.xkb.keymap_new_from_string || + !_glfw.wl.xkb.keymap_unref || + !_glfw.wl.xkb.keymap_mod_get_index || + !_glfw.wl.xkb.keymap_key_repeats || + !_glfw.wl.xkb.keymap_key_get_syms_by_level || + !_glfw.wl.xkb.state_new || + !_glfw.wl.xkb.state_unref || + !_glfw.wl.xkb.state_key_get_syms || + !_glfw.wl.xkb.state_update_mask || + !_glfw.wl.xkb.state_key_get_layout || + !_glfw.wl.xkb.state_mod_index_is_active || + !_glfw.wl.xkb.compose_table_new_from_locale || + !_glfw.wl.xkb.compose_table_unref || + !_glfw.wl.xkb.compose_state_new || + !_glfw.wl.xkb.compose_state_unref || + !_glfw.wl.xkb.compose_state_feed || + !_glfw.wl.xkb.compose_state_get_status || + !_glfw.wl.xkb.compose_state_get_one_sym) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to load all entry points from libxkbcommon"); + return GLFW_FALSE; + } + if (_glfw.hints.init.wl.libdecorMode == GLFW_WAYLAND_PREFER_LIBDECOR) _glfw.wl.libdecor.handle = _glfwPlatformLoadModule("libdecor-0.so.0"); From 6c1e3fd84c35ba212b1eaae75ac13675b5e7f516 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 29 Jan 2024 18:03:47 +0100 Subject: [PATCH 073/137] Win32: Use existing cursor creation path --- src/win32_init.c | 52 +++------------------------------------------- src/win32_window.c | 28 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 49 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index 25fde325..4a75cce6 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -430,46 +430,6 @@ static GLFWbool createHelperWindow(void) return GLFW_TRUE; } -// Creates the blank cursor -// -static void createBlankCursor(void) -{ - // HACK: Create a transparent cursor as using the NULL cursor breaks - // using SetCursorPos when connected over RDP - int cursorWidth = GetSystemMetrics(SM_CXCURSOR); - int cursorHeight = GetSystemMetrics(SM_CYCURSOR); - unsigned char* andMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); - unsigned char* xorMask = _glfw_calloc(cursorWidth * cursorHeight / 8, sizeof(unsigned char)); - - if (andMask != NULL && xorMask != NULL) { - - memset(andMask, 0xFF, (size_t)(cursorWidth * cursorHeight / 8)); - - // Cursor creation might fail, but that's fine as we get NULL in that case, - // which serves as an acceptable fallback blank cursor (other than on RDP) - _glfw.win32.blankCursor = CreateCursor(NULL, 0, 0, cursorWidth, cursorHeight, andMask, xorMask); - - _glfw_free(andMask); - _glfw_free(xorMask); - } -} - -// Initialize for remote sessions -// -static void initRemoteSession(void) -{ - //Check if the current progress was started with Remote Desktop. - _glfw.win32.isRemoteSession = GetSystemMetrics(SM_REMOTESESSION) > 0; - - // With Remote desktop, we need to create a blank cursor because of the cursor is Set to NULL - // if cannot be moved to center in capture mode. If not Remote Desktop win32.blankCursor stays NULL - // and will perform has before (normal). - if (_glfw.win32.isRemoteSession) - { - createBlankCursor(); - } -} - ////////////////////////////////////////////////////////////////////////// ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// @@ -738,14 +698,8 @@ int _glfwInitWin32(void) if (!createHelperWindow()) return GLFW_FALSE; - //Some hacks are needed to support Remote Desktop... - initRemoteSession(); - if (_glfw.win32.isRemoteSession && _glfw.win32.blankCursor == NULL ) - { - _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, - "Win32: Failed to create blank cursor for remote session."); - return GLFW_FALSE; - } + // Check if the current process was started via Remote Desktop + _glfw.win32.isRemoteSession = GetSystemMetrics(SM_REMOTESESSION) > 0; _glfwPollMonitorsWin32(); return GLFW_TRUE; @@ -754,7 +708,7 @@ int _glfwInitWin32(void) void _glfwTerminateWin32(void) { if (_glfw.win32.blankCursor) - DestroyCursor(_glfw.win32.blankCursor); + DestroyIcon((HICON) _glfw.win32.blankCursor); if (_glfw.win32.deviceNotificationHandle) UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle); diff --git a/src/win32_window.c b/src/win32_window.c index 6191f9a4..1a856713 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1314,6 +1314,34 @@ static int createNativeWindow(_GLFWwindow* window, } } + if (_glfw.win32.isRemoteSession) + { + // NOTE: On Remote Desktop, setting the cursor to NULL does not hide it + // HACK: Create a transparent cursor and always set that instead of NULL + // When not on Remote Desktop, this handle is NULL and normal hiding is used + if (!_glfw.win32.blankCursor) + { + const int cursorWidth = GetSystemMetrics(SM_CXCURSOR); + const int cursorHeight = GetSystemMetrics(SM_CYCURSOR); + + unsigned char* cursorPixels = _glfw_calloc(cursorWidth * cursorHeight, 4); + if (!cursorPixels) + return GLFW_FALSE; + + // NOTE: Windows checks whether the image is fully transparent and if so + // just ignores the alpha channel and makes the whole cursor opaque + // HACK: Make one pixel slightly less transparent + cursorPixels[3] = 1; + + const GLFWimage cursorImage = { cursorWidth, cursorHeight, cursorPixels }; + _glfw.win32.blankCursor = createIcon(&cursorImage, 0, 0, FALSE); + _glfw_free(cursorPixels); + + if (!_glfw.win32.blankCursor) + return GLFW_FALSE; + } + } + if (window->monitor) { MONITORINFO mi = { sizeof(mi) }; From 275b92f88721ecc69b15bad2d07fa87a0e77de0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 00:31:19 +0100 Subject: [PATCH 074/137] Win32: Clean up RDP hidden cursor workaround --- src/win32_platform.h | 2 +- src/win32_window.c | 40 +++++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/win32_platform.h b/src/win32_platform.h index 366674fe..43ab3232 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -460,7 +460,7 @@ typedef struct _GLFWlibraryWin32 UINT mouseTrailSize; // Indicate if the process was started behind Remote Destop BOOL isRemoteSession; - // An invisible cursor, needed for special cases (see WM_INPUT handler) + // The cursor handle to use to hide the cursor (NULL or a transparent cursor) HCURSOR blankCursor; struct { diff --git a/src/win32_window.c b/src/win32_window.c index 1a856713..d522e788 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -232,10 +232,12 @@ static void updateCursorImage(_GLFWwindow* window) SetCursor(LoadCursorW(NULL, IDC_ARROW)); } else - //Connected via Remote Desktop, NULL cursor will present SetCursorPos the move the cursor. - //using a blank cursor fix that. - //When not via Remote Desktop, win32.blankCursor should be NULL + { + // NOTE: Via Remote Desktop, setting the cursor to NULL does not hide it. + // HACK: When running locally, it is set to NULL, but when connected via Remote + // Desktop, this is a transparent cursor. SetCursor(_glfw.win32.blankCursor); + } } // Sets the cursor clip rect to the window content area @@ -900,8 +902,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l HRAWINPUT ri = (HRAWINPUT) lParam; RAWINPUT* data = NULL; int dx, dy; - int width, height; - POINT pos; if (_glfw.win32.disabledCursorWindow != window) break; @@ -928,18 +928,29 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l data = _glfw.win32.rawInput; if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE) - { + { if (_glfw.win32.isRemoteSession) { - //Remote Desktop Mode... - // As per https://github.com/Microsoft/DirectXTK/commit/ef56b63f3739381e451f7a5a5bd2c9779d2a7555 - // MOUSE_MOVE_ABSOLUTE is a range from 0 through 65535, based on the screen size. - // As far as I can tell, absolute mode only occurs over RDP though. - width = GetSystemMetrics((data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); - height = GetSystemMetrics((data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); + // NOTE: According to DirectXTK, when running via Remote Desktop, raw + // mouse motion is provided as MOUSE_MOVE_ABSOLUTE and + // MOUSE_VIRTUAL_DESKTOP. - pos.x = (int)((data->data.mouse.lLastX / 65535.0f) * width); - pos.y = (int)((data->data.mouse.lLastY / 65535.0f) * height); + int width, height; + + if (data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) + { + width = GetSystemMetrics(SM_CXVIRTUALSCREEN); + height = GetSystemMetrics(SM_CYVIRTUALSCREEN); + } + else + { + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); + } + + POINT pos; + pos.x = (int) ((data->data.mouse.lLastX / 65535.f) * width); + pos.y = (int) ((data->data.mouse.lLastY / 65535.f) * height); ScreenToClient(window->win32.handle, &pos); dx = pos.x - window->win32.lastCursorPosX; @@ -947,7 +958,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l } else { - //Normal mode... We should have the right absolute coords in data.mouse dx = data->data.mouse.lLastX - window->win32.lastCursorPosX; dy = data->data.mouse.lLastY - window->win32.lastCursorPosY; } From d93868bcf3be1b585dd60205feb340a9cfa59772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 00:59:58 +0100 Subject: [PATCH 075/137] Win32: Fix handling of local absolute raw motion The implementation for how to handle absolute raw motion remotely is just how to handle absolute raw motion, period. --- src/win32_init.c | 3 --- src/win32_platform.h | 2 -- src/win32_window.c | 46 +++++++++++++++++--------------------------- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index 4a75cce6..824e383c 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -698,9 +698,6 @@ int _glfwInitWin32(void) if (!createHelperWindow()) return GLFW_FALSE; - // Check if the current process was started via Remote Desktop - _glfw.win32.isRemoteSession = GetSystemMetrics(SM_REMOTESESSION) > 0; - _glfwPollMonitorsWin32(); return GLFW_TRUE; } diff --git a/src/win32_platform.h b/src/win32_platform.h index 43ab3232..feecb753 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -458,8 +458,6 @@ typedef struct _GLFWlibraryWin32 RAWINPUT* rawInput; int rawInputSize; UINT mouseTrailSize; - // Indicate if the process was started behind Remote Destop - BOOL isRemoteSession; // The cursor handle to use to hide the cursor (NULL or a transparent cursor) HCURSOR blankCursor; diff --git a/src/win32_window.c b/src/win32_window.c index d522e788..e6a9496c 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -929,38 +929,28 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l data = _glfw.win32.rawInput; if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE) { - if (_glfw.win32.isRemoteSession) + POINT pos = {0}; + int width, height; + + if (data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) { - // NOTE: According to DirectXTK, when running via Remote Desktop, raw - // mouse motion is provided as MOUSE_MOVE_ABSOLUTE and - // MOUSE_VIRTUAL_DESKTOP. - - int width, height; - - if (data->data.mouse.usFlags & MOUSE_VIRTUAL_DESKTOP) - { - width = GetSystemMetrics(SM_CXVIRTUALSCREEN); - height = GetSystemMetrics(SM_CYVIRTUALSCREEN); - } - else - { - width = GetSystemMetrics(SM_CXSCREEN); - height = GetSystemMetrics(SM_CYSCREEN); - } - - POINT pos; - pos.x = (int) ((data->data.mouse.lLastX / 65535.f) * width); - pos.y = (int) ((data->data.mouse.lLastY / 65535.f) * height); - ScreenToClient(window->win32.handle, &pos); - - dx = pos.x - window->win32.lastCursorPosX; - dy = pos.y - window->win32.lastCursorPosY; + pos.x += GetSystemMetrics(SM_XVIRTUALSCREEN); + pos.y += GetSystemMetrics(SM_YVIRTUALSCREEN); + width = GetSystemMetrics(SM_CXVIRTUALSCREEN); + height = GetSystemMetrics(SM_CYVIRTUALSCREEN); } else { - dx = data->data.mouse.lLastX - window->win32.lastCursorPosX; - dy = data->data.mouse.lLastY - window->win32.lastCursorPosY; + width = GetSystemMetrics(SM_CXSCREEN); + height = GetSystemMetrics(SM_CYSCREEN); } + + pos.x += (int) ((data->data.mouse.lLastX / 65535.f) * width); + pos.y += (int) ((data->data.mouse.lLastY / 65535.f) * height); + ScreenToClient(window->win32.handle, &pos); + + dx = pos.x - window->win32.lastCursorPosX; + dy = pos.y - window->win32.lastCursorPosY; } else { @@ -1324,7 +1314,7 @@ static int createNativeWindow(_GLFWwindow* window, } } - if (_glfw.win32.isRemoteSession) + if (GetSystemMetrics(SM_REMOTESESSION)) { // NOTE: On Remote Desktop, setting the cursor to NULL does not hide it // HACK: Create a transparent cursor and always set that instead of NULL From fb10e95f78b041c424cbca7a71bf51508492855f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Feb 2024 20:16:04 +0100 Subject: [PATCH 076/137] Add language tags for C code sections --- docs/build.dox | 6 +-- docs/context.dox | 24 ++++----- docs/input.dox | 110 +++++++++++++++++++------------------- docs/intro.dox | 38 +++++++------- docs/monitor.dox | 28 +++++----- docs/moving.dox | 44 ++++++++-------- docs/quick.dox | 40 +++++++------- docs/vulkan.dox | 24 ++++----- docs/window.dox | 134 +++++++++++++++++++++++------------------------ 9 files changed, 224 insertions(+), 224 deletions(-) diff --git a/docs/build.dox b/docs/build.dox index a1625d60..3d9ca845 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -21,7 +21,7 @@ the documentation for your development environment. You should include the GLFW header in the source files where you use OpenGL or GLFW. -@code +@code{.c} #include @endcode @@ -50,7 +50,7 @@ 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 +@code{.c} #include #include @endcode @@ -61,7 +61,7 @@ macro. If yours doesn't or you don't know which one your users will pick, the including the OpenGL header. This will also allow you to include the two headers in any order. -@code +@code{.c} #define GLFW_INCLUDE_NONE #include #include diff --git a/docs/context.dox b/docs/context.dox index 21672ad7..67ff7583 100644 --- a/docs/context.dox +++ b/docs/context.dox @@ -47,7 +47,7 @@ When creating a window and its OpenGL or OpenGL ES context with @ref glfwCreateWindow, you can specify another window whose context the new one should share its objects (textures, vertex and element buffers, etc.) with. -@code +@code{.c} GLFWwindow* second_window = glfwCreateWindow(640, 480, "Second Window", NULL, first_window); @endcode @@ -70,7 +70,7 @@ GLFW doesn't support creating contexts without an associated window. However, contexts with hidden windows can be created with the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint. -@code +@code{.c} glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); GLFWwindow* offscreen_context = glfwCreateWindow(640, 480, "", NULL, NULL); @@ -105,13 +105,13 @@ thread before making it current on the new one. The context of a window is made current with @ref glfwMakeContextCurrent. -@code +@code{.c} glfwMakeContextCurrent(window); @endcode The window of the current context is returned by @ref glfwGetCurrentContext. -@code +@code{.c} GLFWwindow* window = glfwGetCurrentContext(); @endcode @@ -185,14 +185,14 @@ include the glad header file, which will replace the OpenGL header of your development environment. By including the glad header before the GLFW header, it suppresses the development environment's OpenGL or OpenGL ES header. -@code +@code{.c} #include #include @endcode Finally, you need to initialize glad once you have a suitable current context. -@code +@code{.c} window = glfwCreateWindow(640, 480, "My Window", NULL, NULL); if (!window) { @@ -215,7 +215,7 @@ check the actual OpenGL or OpenGL ES version with a specific version is supported by the current context with the `GLAD_GL_VERSION_x_x` booleans. -@code +@code{.c} if (GLAD_GL_VERSION_3_2) { // Call OpenGL 3.2+ specific code @@ -225,7 +225,7 @@ if (GLAD_GL_VERSION_3_2) To check whether a specific extension is supported, use the `GLAD_GL_xxx` booleans. -@code +@code{.c} if (GLAD_GL_ARB_gl_spirv) { // Use GL_ARB_gl_spirv @@ -267,7 +267,7 @@ to function) and `PROC` (procedure) are added to the ends. To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including the GLFW header. -@code +@code{.c} #define GLFW_INCLUDE_GLEXT #include @endcode @@ -280,7 +280,7 @@ drivers or a graphics card that lacks the necessary hardware features), so it is necessary to check at run-time whether the context supports the extension. This is done with @ref glfwExtensionSupported. -@code +@code{.c} if (glfwExtensionSupported("GL_ARB_gl_spirv")) { // The extension is supported by the current context @@ -299,7 +299,7 @@ These functions often do not have entry points in the client API libraries of your operating system, making it necessary to fetch them at run time. You can retrieve pointers to these functions with @ref glfwGetProcAddress. -@code +@code{.c} PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB"); @endcode @@ -310,7 +310,7 @@ use a different prefix, like above, or some other naming scheme. Now that all the pieces have been introduced, here is what they might look like when used together. -@code +@code{.c} #define GLFW_INCLUDE_GLEXT #include diff --git a/docs/input.dox b/docs/input.dox index f57520bb..f3ccbb2b 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -42,7 +42,7 @@ There are three functions for processing pending events. @ref glfwPollEvents, processes only those events that have already been received and then returns immediately. -@code +@code{.c} glfwPollEvents(); @endcode @@ -51,7 +51,7 @@ This is the best choice when rendering continuously, like most games do. If you only need to update the contents of the window when you receive new input, @ref glfwWaitEvents is a better choice. -@code +@code{.c} glfwWaitEvents(); @endcode @@ -62,7 +62,7 @@ useful for, for example, editing tools. If you want to wait for events but have UI elements or other tasks that need periodic updates, @ref glfwWaitEventsTimeout lets you specify a timeout. -@code +@code{.c} glfwWaitEventsTimeout(0.7); @endcode @@ -74,7 +74,7 @@ If the main thread is sleeping in @ref glfwWaitEvents, you can wake it from another thread by posting an empty event to the event queue with @ref glfwPostEmptyEvent. -@code +@code{.c} glfwPostEmptyEvent(); @endcode @@ -108,14 +108,14 @@ same keyboard layout, input method or even operating system as you. If you wish to be notified when a physical key is pressed or released or when it repeats, set a key callback. -@code +@code{.c} glfwSetKeyCallback(window, key_callback); @endcode The callback function receives the [keyboard key](@ref keys), platform-specific scancode, key action and [modifier bits](@ref mods). -@code +@code{.c} void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_E && action == GLFW_PRESS) @@ -149,7 +149,7 @@ different scancodes depending on the platform but they are safe to save to disk. You can query the scancode for any [key token](@ref keys) supported on the current platform with @ref glfwGetKeyScancode. -@code +@code{.c} const int scancode = glfwGetKeyScancode(GLFW_KEY_X); set_key_mapping(scancode, swap_weapons); @endcode @@ -157,7 +157,7 @@ set_key_mapping(scancode, swap_weapons); The last reported state for every physical key with a [key token](@ref keys) is also saved in per-window state arrays that can be polled with @ref glfwGetKey. -@code +@code{.c} int state = glfwGetKey(window, GLFW_KEY_E); if (state == GLFW_PRESS) { @@ -177,7 +177,7 @@ If a pressed key is released again before you poll its state, you will have missed the key press. The recommended solution for this is to use a key callback, but there is also the `GLFW_STICKY_KEYS` input mode. -@code +@code{.c} glfwSetInputMode(window, GLFW_STICKY_KEYS, GLFW_TRUE); @endcode @@ -190,7 +190,7 @@ the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`. If you wish to know what the state of the Caps Lock and Num Lock keys was when input events were generated, set the `GLFW_LOCK_KEY_MODS` input mode. -@code +@code{.c} glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, GLFW_TRUE); @endcode @@ -217,7 +217,7 @@ you can treat the code point argument as native endian UTF-32. If you wish to offer regular text input, set a character callback. -@code +@code{.c} glfwSetCharCallback(window, character_callback); @endcode @@ -225,7 +225,7 @@ The callback function receives Unicode code points for key events that would have led to regular text input and generally behaves as a standard text field on that platform. -@code +@code{.c} void character_callback(GLFWwindow* window, unsigned int codepoint) { } @@ -237,7 +237,7 @@ void character_callback(GLFWwindow* window, unsigned int codepoint) If you wish to refer to keys by name, you can query the keyboard layout dependent name of printable keys with @ref glfwGetKeyName. -@code +@code{.c} const char* key_name = glfwGetKeyName(GLFW_KEY_W, 0); show_tutorial_hint("Press %s to move forward", key_name); @endcode @@ -260,7 +260,7 @@ a custom image or a standard cursor shape from the system theme. If you wish to be notified when the cursor moves over the window, set a cursor position callback. -@code +@code{.c} glfwSetCursorPosCallback(window, cursor_position_callback); @endcode @@ -268,7 +268,7 @@ The callback functions receives the cursor position, measured in screen coordinates but relative to the top-left corner of the window content area. On platforms that provide it, the full sub-pixel cursor position is passed on. -@code +@code{.c} static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos) { } @@ -277,7 +277,7 @@ static void cursor_position_callback(GLFWwindow* window, double xpos, double ypo The cursor position is also saved per-window and can be polled with @ref glfwGetCursorPos. -@code +@code{.c} double xpos, ypos; glfwGetCursorPos(window, &xpos, &ypos); @endcode @@ -295,7 +295,7 @@ If you wish to implement mouse motion based camera controls or other input schemes that require unlimited mouse movement, set the cursor mode to `GLFW_CURSOR_DISABLED`. -@code +@code{.c} glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); @endcode @@ -311,7 +311,7 @@ other features of GLFW. It is not supported and will not work as robustly as If you only wish the cursor to become hidden when it is over a window but still want it to behave normally, set the cursor mode to `GLFW_CURSOR_HIDDEN`. -@code +@code{.c} glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); @endcode @@ -320,7 +320,7 @@ This mode puts no limit on the motion of the cursor. If you wish the cursor to be visible but confined to the content area of the window, set the cursor mode to `GLFW_CURSOR_CAPTURED`. -@code +@code{.c} glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED); @endcode @@ -330,7 +330,7 @@ leave unless the window loses focus. To exit out of either of these special modes, restore the `GLFW_CURSOR_NORMAL` cursor mode. -@code +@code{.c} glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); @endcode @@ -353,7 +353,7 @@ Call @ref glfwRawMouseMotionSupported to check if the current machine provides raw motion and set the `GLFW_RAW_MOUSE_MOTION` input mode to enable it. It is disabled by default. -@code +@code{.c} if (glfwRawMouseMotionSupported()) glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE); @endcode @@ -376,7 +376,7 @@ A custom cursor is created with @ref glfwCreateCursor, which returns a handle to the created cursor object. For example, this creates a 16x16 white square cursor with the hot-spot in the upper-left corner: -@code +@code{.c} unsigned char pixels[16 * 16 * 4]; memset(pixels, 0xff, sizeof(pixels)); @@ -401,7 +401,7 @@ sequential rows, starting from the top-left corner. A cursor with a [standard shape](@ref shapes) from the current system cursor theme can be created with @ref glfwCreateStandardCursor. -@code +@code{.c} GLFWcursor* url_cursor = glfwCreateStandardCursor(GLFW_POINTING_HAND_CURSOR); @endcode @@ -416,7 +416,7 @@ A few of these shapes are not available everywhere. If a shape is unavailable, When a cursor is no longer needed, destroy it with @ref glfwDestroyCursor. -@code +@code{.c} glfwDestroyCursor(cursor); @endcode @@ -429,7 +429,7 @@ mode. All remaining cursors are destroyed when @ref glfwTerminate is called. A cursor can be set as current for a window with @ref glfwSetCursor. -@code +@code{.c} glfwSetCursor(window, cursor); @endcode @@ -441,7 +441,7 @@ A single cursor may be set for any number of windows. To revert to the default cursor, set the cursor of that window to `NULL`. -@code +@code{.c} glfwSetCursor(window, NULL); @endcode @@ -454,13 +454,13 @@ default cursor. This does not affect the cursor mode. If you wish to be notified when the cursor enters or leaves the content area of a window, set a cursor enter/leave callback. -@code +@code{.c} glfwSetCursorEnterCallback(window, cursor_enter_callback); @endcode The callback function receives the new classification of the cursor. -@code +@code{.c} void cursor_enter_callback(GLFWwindow* window, int entered) { if (entered) @@ -477,7 +477,7 @@ void cursor_enter_callback(GLFWwindow* window, int entered) You can query whether the cursor is currently inside the content area of the window with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute. -@code +@code{.c} if (glfwGetWindowAttrib(window, GLFW_HOVERED)) { highlight_interface(); @@ -490,14 +490,14 @@ if (glfwGetWindowAttrib(window, GLFW_HOVERED)) If you wish to be notified when a mouse button is pressed or released, set a mouse button callback. -@code +@code{.c} glfwSetMouseButtonCallback(window, mouse_button_callback); @endcode The callback function receives the [mouse button](@ref buttons), button action and [modifier bits](@ref mods). -@code +@code{.c} void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) @@ -511,7 +511,7 @@ The last reported state for every [supported mouse button](@ref buttons) is also saved in per-window state arrays that can be polled with @ref glfwGetMouseButton. -@code +@code{.c} int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT); if (state == GLFW_PRESS) { @@ -531,7 +531,7 @@ missed the button press. The recommended solution for this is to use a mouse button callback, but there is also the `GLFW_STICKY_MOUSE_BUTTONS` input mode. -@code +@code{.c} glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, GLFW_TRUE); @endcode @@ -550,13 +550,13 @@ The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any If you wish to be notified when the user scrolls, whether with a mouse wheel or touchpad gesture, set a scroll callback. -@code +@code{.c} glfwSetScrollCallback(window, scroll_callback); @endcode The callback function receives two-dimensional scroll offsets. -@code +@code{.c} void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { } @@ -573,7 +573,7 @@ referred to as joysticks. It supports up to sixteen joysticks, ranging from `GLFW_JOYSTICK_LAST`. You can test whether a [joystick](@ref joysticks) is present with @ref glfwJoystickPresent. -@code +@code{.c} int present = glfwJoystickPresent(GLFW_JOYSTICK_1); @endcode @@ -601,7 +601,7 @@ The positions of all axes of a joystick are returned by @ref glfwGetJoystickAxes. See the reference documentation for the lifetime of the returned array. -@code +@code{.c} int count; const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_5, &count); @endcode @@ -615,7 +615,7 @@ The states of all buttons of a joystick are returned by @ref glfwGetJoystickButtons. See the reference documentation for the lifetime of the returned array. -@code +@code{.c} int count; const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_3, &count); @endcode @@ -632,7 +632,7 @@ the reference documentation for @ref glfwGetJoystickButtons for details. The states of all hats are returned by @ref glfwGetJoystickHats. See the reference documentation for the lifetime of the returned array. -@code +@code{.c} int count; const unsigned char* hats = glfwGetJoystickHats(GLFW_JOYSTICK_7, &count); @endcode @@ -655,7 +655,7 @@ The diagonal directions are bitwise combinations of the primary (up, right, down and left) directions and you can test for these individually by ANDing it with the corresponding direction. -@code +@code{.c} if (hats[2] & GLFW_HAT_RIGHT) { // State of hat 2 could be right-up, right or right-down @@ -673,7 +673,7 @@ The human-readable, UTF-8 encoded name of a joystick is returned by @ref glfwGetJoystickName. See the reference documentation for the lifetime of the returned string. -@code +@code{.c} const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4); @endcode @@ -698,14 +698,14 @@ The initial value of the pointer is `NULL`. If you wish to be notified when a joystick is connected or disconnected, set a joystick callback. -@code +@code{.c} glfwSetJoystickCallback(joystick_callback); @endcode The callback function receives the ID of the joystick that has been connected and disconnected and the event that occurred. -@code +@code{.c} void joystick_callback(int jid, int event) { if (event == GLFW_CONNECTED) @@ -748,7 +748,7 @@ a joystick is connected or the mappings are updated. You can check whether a joystick is both present and has a gamepad mapping with @ref glfwJoystickIsGamepad. -@code +@code{.c} if (glfwJoystickIsGamepad(GLFW_JOYSTICK_2)) { // Use as gamepad @@ -762,13 +762,13 @@ You can query the human-readable name provided by the gamepad mapping with @ref glfwGetGamepadName. This may or may not be the same as the [joystick name](@ref joystick_name). -@code +@code{.c} const char* name = glfwGetGamepadName(GLFW_JOYSTICK_7); @endcode To retrieve the gamepad state of a joystick, call @ref glfwGetGamepadState. -@code +@code{.c} GLFWgamepadstate state; if (glfwGetGamepadState(GLFW_JOYSTICK_3, &state)) @@ -818,7 +818,7 @@ GLFW contains a copy of the mappings available in time of release. Newer ones can be added at runtime with @ref glfwUpdateGamepadMappings. -@code +@code{.c} const char* mappings = load_file_contents("game/data/gamecontrollerdb.txt"); glfwUpdateGamepadMappings(mappings); @@ -898,7 +898,7 @@ and described above. GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime. -@code +@code{.c} double seconds = glfwGetTime(); @endcode @@ -908,7 +908,7 @@ nanosecond resolution. You can modify the base time with @ref glfwSetTime. -@code +@code{.c} glfwSetTime(4.0); @endcode @@ -918,7 +918,7 @@ from there. You can also access the raw timer used to implement the functions above, with @ref glfwGetTimerValue. -@code +@code{.c} uint64_t value = glfwGetTimerValue(); @endcode @@ -926,7 +926,7 @@ 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 +@code{.c} uint64_t frequency = glfwGetTimerFrequency(); @endcode @@ -937,7 +937,7 @@ If the system clipboard contains a UTF-8 encoded string or if it can be converted to one, you can retrieve it with @ref glfwGetClipboardString. See the reference documentation for the lifetime of the returned string. -@code +@code{.c} const char* text = glfwGetClipboardString(NULL); if (text) { @@ -951,7 +951,7 @@ returned. The contents of the system clipboard can be set to a UTF-8 encoded string with @ref glfwSetClipboardString. -@code +@code{.c} glfwSetClipboardString(NULL, "A string with words in it"); @endcode @@ -961,13 +961,13 @@ glfwSetClipboardString(NULL, "A string with words in it"); If you wish to receive the paths of files and/or directories dropped on a window, set a file drop callback. -@code +@code{.c} glfwSetDropCallback(window, drop_callback); @endcode The callback function receives an array of paths encoded as UTF-8. -@code +@code{.c} void drop_callback(GLFWwindow* window, int count, const char** paths) { int i; diff --git a/docs/intro.dox b/docs/intro.dox index bfb3ddcd..7a47e034 100644 --- a/docs/intro.dox +++ b/docs/intro.dox @@ -48,7 +48,7 @@ GLFW_NOT_INITIALIZED error. The library is initialized with @ref glfwInit, which returns `GLFW_FALSE` if an error occurred. -@code +@code{.c} if (!glfwInit()) { // Handle initialization failure @@ -76,7 +76,7 @@ hint. Initialization hints are set before @ref glfwInit and affect how the library behaves until termination. Hints are set with @ref glfwInitHint. -@code +@code{.c} glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE); @endcode @@ -176,7 +176,7 @@ default, this is set to @ref GLFW_ANY_PLATFORM, which will look for supported wi systems in order of priority and select the first one it finds. It can also be set to any specific platform to have GLFW only look for that one. -@code +@code{.c} glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11); @endcode @@ -184,14 +184,14 @@ This mechanism also provides the Null platform, which is always supported but ne explicitly requested. This platform is effectively a stub, emulating a window system on a single 1080p monitor, but will not interact with any actual window system. -@code +@code{.c} glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL); @endcode You can test whether a library binary was compiled with support for a specific platform with @ref glfwPlatformSupported. -@code +@code{.c} if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND); @endcode @@ -199,7 +199,7 @@ if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) Once GLFW has been initialized, you can query which platform was selected with @ref glfwGetPlatform. -@code +@code{.c} int platform = glfwGetPlatform(); @endcode @@ -213,7 +213,7 @@ selected platform. The heap memory allocator can be customized before initialization with @ref glfwInitAllocator. -@code +@code{.c} GLFWallocator allocator; allocator.allocate = my_malloc; allocator.reallocate = my_realloc; @@ -235,7 +235,7 @@ The allocation function must have a signature matching @ref GLFWallocatefun. It the desired size, in bytes, and the user pointer passed to @ref glfwInitAllocator and returns the address to the allocated memory block. -@code +@code{.c} void* my_malloc(size_t size, void* user) { ... @@ -250,7 +250,7 @@ It receives the memory block to be reallocated, the new desired size, in bytes, pointer passed to @ref glfwInitAllocator and returns the address to the resized memory block. -@code +@code{.c} void* my_realloc(void* block, size_t size, void* user) { ... @@ -264,7 +264,7 @@ The deallocation function must have a function signature matching @ref GLFWdeall It receives the memory block to be deallocated and the user pointer passed to @ref glfwInitAllocator. -@code +@code{.c} void my_free(void* block, void* user) { ... @@ -280,7 +280,7 @@ for a deallocation function. If the active one does not meet all of these, GLFW Before your application exits, you should terminate the GLFW library if it has been initialized. This is done with @ref glfwTerminate. -@code +@code{.c} glfwTerminate(); @endcode @@ -305,7 +305,7 @@ values. The last [error code](@ref errors) for the calling thread can be queried at any time with @ref glfwGetError. -@code +@code{.c} int code = glfwGetError(NULL); if (code != GLFW_NO_ERROR) @@ -324,7 +324,7 @@ can retrieve a UTF-8 encoded human-readable description along with the error code. If no error has occurred since the last call, the description is set to `NULL`. -@code +@code{.c} const char* description; int code = glfwGetError(&description); @@ -338,14 +338,14 @@ This means you must make a copy of it if you want to keep it. You can also set an error callback, which will be called each time an error occurs. It is set with @ref glfwSetErrorCallback. -@code +@code{.c} glfwSetErrorCallback(error_callback); @endcode The error callback receives the same error code and human-readable description returned by @ref glfwGetError. -@code +@code{.c} void error_callback(int code, const char* description) { display_error_message(code, description); @@ -572,7 +572,7 @@ this to verify that the library binary is compatible with your application. The compile-time version of GLFW is provided by the GLFW header with the `GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros. -@code +@code{.c} printf("Compiled against GLFW %i.%i.%i\n", GLFW_VERSION_MAJOR, GLFW_VERSION_MINOR, @@ -585,7 +585,7 @@ printf("Compiled against GLFW %i.%i.%i\n", The run-time version can be retrieved with @ref glfwGetVersion, a function that may be called regardless of whether GLFW is initialized. -@code +@code{.c} int major, minor, revision; glfwGetVersion(&major, &minor, &revision); @@ -624,14 +624,14 @@ The format of the string is as follows: For example, compiling GLFW 3.4 with MinGW as a DLL for Windows, may result in a version string like this: -@code +@code{.c} 3.4.0 Win32 WGL Null EGL OSMesa MinGW DLL @endcode Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may result in a version string like this: -@code +@code{.c} 3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic @endcode diff --git a/docs/monitor.dox b/docs/monitor.dox index b4099dbf..c94ab01a 100644 --- a/docs/monitor.dox +++ b/docs/monitor.dox @@ -42,14 +42,14 @@ The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is the user's preferred monitor and is usually the one with global UI elements like task bar or menu bar. -@code +@code{.c} GLFWmonitor* primary = glfwGetPrimaryMonitor(); @endcode You can retrieve all currently connected monitors with @ref glfwGetMonitors. See the reference documentation for the lifetime of the returned array. -@code +@code{.c} int count; GLFWmonitor** monitors = glfwGetMonitors(&count); @endcode @@ -64,14 +64,14 @@ disconnected. If you wish to be notified when a monitor is connected or disconnected, set a monitor callback. -@code +@code{.c} glfwSetMonitorCallback(monitor_callback); @endcode The callback function receives the handle for the monitor that has been connected or disconnected and the event that occurred. -@code +@code{.c} void monitor_callback(GLFWmonitor* monitor, int event) { if (event == GLFW_CONNECTED) @@ -109,7 +109,7 @@ Video modes are represented as @ref GLFWvidmode structures. You can get an array of the video modes supported by a monitor with @ref glfwGetVideoModes. See the reference documentation for the lifetime of the returned array. -@code +@code{.c} int count; GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); @endcode @@ -117,7 +117,7 @@ GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); To get the current video mode of a monitor call @ref glfwGetVideoMode. See the reference documentation for the lifetime of the returned pointer. -@code +@code{.c} const GLFWvidmode* mode = glfwGetVideoMode(monitor); @endcode @@ -132,7 +132,7 @@ retrieved with @ref glfwGetMonitorPhysicalSize. This has no relation to its current _resolution_, i.e. the width and height of its current [video mode](@ref monitor_modes). -@code +@code{.c} int width_mm, height_mm; glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm); @endcode @@ -147,7 +147,7 @@ useful. Instead, use the [monitor content scale](@ref monitor_scale) and The content scale for a monitor can be retrieved with @ref glfwGetMonitorContentScale. -@code +@code{.c} float xscale, yscale; glfwGetMonitorContentScale(monitor, &xscale, &yscale); @endcode @@ -170,7 +170,7 @@ The position of the monitor on the virtual desktop, in [screen coordinates](@ref coordinate_systems), can be retrieved with @ref glfwGetMonitorPos. -@code +@code{.c} int xpos, ypos; glfwGetMonitorPos(monitor, &xpos, &ypos); @endcode @@ -182,7 +182,7 @@ The area of a monitor not occupied by global task bars or menu bars is the work area. This is specified in [screen coordinates](@ref coordinate_systems) and can be retrieved with @ref glfwGetMonitorWorkarea. -@code +@code{.c} int xpos, ypos, width, height; glfwGetMonitorWorkarea(monitor, &xpos, &ypos, &width, &height); @endcode @@ -194,7 +194,7 @@ The human-readable, UTF-8 encoded name of a monitor is returned by @ref glfwGetMonitorName. See the reference documentation for the lifetime of the returned string. -@code +@code{.c} const char* name = glfwGetMonitorName(monitor); @endcode @@ -219,7 +219,7 @@ The initial value of the pointer is `NULL`. The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts a monitor handle and a pointer to a @ref GLFWgammaramp structure. -@code +@code{.c} GLFWgammaramp ramp; unsigned short red[256], green[256], blue[256]; @@ -245,7 +245,7 @@ ramp for that monitor. The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. See the reference documentation for the lifetime of the returned structure. -@code +@code{.c} const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor); @endcode @@ -253,7 +253,7 @@ If you wish to set a regular gamma ramp, you can have GLFW calculate it for you from the desired exponent with @ref glfwSetGamma, which in turn calls @ref glfwSetGammaRamp with the resulting ramp. -@code +@code{.c} glfwSetGamma(monitor, 1.0); @endcode diff --git a/docs/moving.dox b/docs/moving.dox index 705b4fa8..51ca4c4a 100644 --- a/docs/moving.dox +++ b/docs/moving.dox @@ -22,12 +22,12 @@ Unix-like systems, where it uses the [soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`. @par Old syntax -@code +@code{.c} #include @endcode @par New syntax -@code +@code{.c} #include @endcode @@ -95,12 +95,12 @@ the creation of DLLs and DLL link libraries, as there's no need to explicitly disable `@n` entry point suffixes. @par Old syntax -@code +@code{.c} void GLFWCALL callback_function(...); @endcode @par New syntax -@code +@code{.c} void callback_function(...); @endcode @@ -114,12 +114,12 @@ a newly created window is returned by @ref glfwCreateWindow (formerly [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow. @par Old syntax -@code +@code{.c} glfwSetWindowTitle("New Window Title"); @endcode @par New syntax -@code +@code{.c} glfwSetWindowTitle(window, "New Window Title"); @endcode @@ -134,12 +134,12 @@ GLFW 2 would have selected, but there are many other [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor. @par Old basic full screen -@code +@code{.c} glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN); @endcode @par New basic full screen -@code +@code{.c} window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL); @endcode @@ -156,7 +156,7 @@ buffer swap, which acts on a single window, the event processing functions act on all windows at once. @par Old basic main loop -@code +@code{.c} while (...) { // Process input @@ -166,7 +166,7 @@ while (...) @endcode @par New basic main loop -@code +@code{.c} while (...) { // Process input @@ -198,13 +198,13 @@ glfwGetFramebufferSize function. A framebuffer size callback has also been added, which can be set with @ref glfwSetFramebufferSizeCallback. @par Old basic viewport setup -@code +@code{.c} glfwGetWindowSize(&width, &height); glViewport(0, 0, width, height); @endcode @par New basic viewport setup -@code +@code{.c} glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); @endcode @@ -227,7 +227,7 @@ You can query the close flag at any time with @ref glfwWindowShouldClose and set it at any time with @ref glfwSetWindowShouldClose. @par Old basic main loop -@code +@code{.c} while (glfwGetWindowParam(GLFW_OPENED)) { ... @@ -235,7 +235,7 @@ while (glfwGetWindowParam(GLFW_OPENED)) @endcode @par New basic main loop -@code +@code{.c} while (!glfwWindowShouldClose(window)) { ... @@ -248,12 +248,12 @@ event processing completes. You may however not call @ref glfwDestroyWindow from the close callback (or any other window related callback). @par Old syntax -@code +@code{.c} int GLFWCALL window_close_callback(void); @endcode @par New syntax -@code +@code{.c} void window_close_callback(GLFWwindow* window); @endcode @@ -289,12 +289,12 @@ produce characters with diacritical marks. Even the Swedish keyboard layout requires this for uncommon cases like ü. @par Old syntax -@code +@code{.c} void GLFWCALL character_callback(int character, int action); @endcode @par New syntax -@code +@code{.c} void character_callback(GLFWwindow* window, int character); @endcode @@ -324,12 +324,12 @@ two-dimensional floating point scroll offsets. This allows you to receive precise scroll data from for example modern touchpads. @par Old syntax -@code +@code{.c} void GLFWCALL mouse_wheel_callback(int position); @endcode @par New syntax -@code +@code{.c} void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); @endcode @@ -437,12 +437,12 @@ has been moved to GLFW 3, you can request that the GLFW header includes it by defining @ref GLFW_INCLUDE_GLU before the inclusion of the GLFW header. @par Old syntax -@code +@code{.c} #include @endcode @par New syntax -@code +@code{.c} #define GLFW_INCLUDE_GLU #include @endcode diff --git a/docs/quick.dox b/docs/quick.dox index 8824ff5b..037f11e2 100644 --- a/docs/quick.dox +++ b/docs/quick.dox @@ -21,7 +21,7 @@ behave differently in GLFW 3. In the source files of your application where you use GLFW, you need to include its header file. -@code +@code{.c} #include @endcode @@ -38,7 +38,7 @@ 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 +@code{.c} #include #include @endcode @@ -48,7 +48,7 @@ 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 +@code{.c} #define GLFW_INCLUDE_NONE #include #include @@ -61,7 +61,7 @@ Before you can use most GLFW functions, the library must be initialized. On successful initialization, `GLFW_TRUE` is returned. If an error occurred, `GLFW_FALSE` is returned. -@code +@code{.c} if (!glfwInit()) { // Initialization failed @@ -73,7 +73,7 @@ Note that `GLFW_TRUE` and `GLFW_FALSE` are and will always be one and zero. When you are done using GLFW, typically just before the application exits, you need to terminate GLFW. -@code +@code{.c} glfwTerminate(); @endcode @@ -92,7 +92,7 @@ In case a GLFW function fails, an error is reported to the GLFW error callback. You can receive these reports with an error callback. This function must have the signature below but may do anything permitted in other callbacks. -@code +@code{.c} void error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); @@ -104,7 +104,7 @@ the error callback is one of the few GLFW functions that may be called before initialization, which lets you be notified of errors both during and after initialization. -@code +@code{.c} glfwSetErrorCallback(error_callback); @endcode @@ -115,7 +115,7 @@ The window and its OpenGL context are created with a single call to @ref glfwCreateWindow, which returns a handle to the created combined window and context object -@code +@code{.c} GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); if (!window) { @@ -138,7 +138,7 @@ 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 +@code{.c} glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); @@ -151,7 +151,7 @@ if (!window) When a window and context is no longer needed, destroy it. -@code +@code{.c} glfwDestroyWindow(window); @endcode @@ -163,7 +163,7 @@ and its handle becomes invalid. Before you can use the OpenGL API, you must have a current OpenGL context. -@code +@code{.c} glfwMakeContextCurrent(window); @endcode @@ -176,7 +176,7 @@ a current context to load from. This example uses [glad](https://github.com/Dav1dde/glad), but the same rule applies to all such libraries. -@code +@code{.c} gladLoadGL(glfwGetProcAddress); @endcode @@ -191,7 +191,7 @@ Note that __the window isn't actually closed__, so you are expected to monitor this flag and either destroy the window or give some kind of feedback to the user. -@code +@code{.c} while (!glfwWindowShouldClose(window)) { // Keep running @@ -213,7 +213,7 @@ Each window has a large number of callbacks that can be set to receive all the various kinds of events. To receive key press and release events, create a key callback function. -@code +@code{.c} static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) @@ -223,7 +223,7 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, The key callback, like other window related callbacks, are set per-window. -@code +@code{.c} glfwSetKeyCallback(window, key_callback); @endcode @@ -237,7 +237,7 @@ Once you have a current OpenGL context, you can use OpenGL normally. In this tutorial, a multicolored rotating triangle will be rendered. The framebuffer size needs to be retrieved for `glViewport`. -@code +@code{.c} int width, height; glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); @@ -265,7 +265,7 @@ returns the number of seconds since initialization. The time source used is the most accurate on each platform and generally has micro- or nanosecond resolution. -@code +@code{.c} double time = glfwGetTime(); @endcode @@ -279,7 +279,7 @@ the one being displayed and the back buffer the one you render to. When the entire frame has been rendered, the buffers need to be swapped with one another, so the back buffer becomes the front buffer and vice versa. -@code +@code{.c} glfwSwapBuffers(window); @endcode @@ -296,7 +296,7 @@ For these reasons, applications will typically want to set the swap interval to one. It can be set to higher values, but this is usually not recommended, because of the input latency it leads to. -@code +@code{.c} glfwSwapInterval(1); @endcode @@ -315,7 +315,7 @@ There are two methods for processing pending events; polling and waiting. This example will use event polling, which processes only those events that have already been received and then returns immediately. -@code +@code{.c} glfwPollEvents(); @endcode diff --git a/docs/vulkan.dox b/docs/vulkan.dox index 5e38c014..167f3456 100644 --- a/docs/vulkan.dox +++ b/docs/vulkan.dox @@ -45,7 +45,7 @@ you will need to direct GLFW to it. Pass your version of `vkGetInstanceProcAddr glfwInitVulkanLoader before initializing GLFW and it will use that function for all Vulkan entry point retrieval. This prevents GLFW from dynamically loading the Vulkan loader. -@code +@code{.c} glfwInitVulkanLoader(vkGetInstanceProcAddr); @endcode @@ -59,7 +59,7 @@ bundle according to the LunarG SDK documentation. This is explained in more det To have GLFW include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including the GLFW header. -@code +@code{.c} #define GLFW_INCLUDE_VULKAN #include @endcode @@ -67,7 +67,7 @@ the GLFW header. If you instead want to include the Vulkan header from a custom location or use your own custom Vulkan header then do this before the GLFW header. -@code +@code{.c} #include #include @endcode @@ -94,7 +94,7 @@ If you are loading the Vulkan loader dynamically instead of linking directly against it, you can check for the availability of a loader and ICD with @ref glfwVulkanSupported. -@code +@code{.c} if (glfwVulkanSupported()) { // Vulkan is available, at least for compute @@ -114,7 +114,7 @@ To load any Vulkan core or extension function from the found loader, call @ref glfwGetInstanceProcAddress. To load functions needed for instance creation, pass `NULL` as the instance. -@code +@code{.c} PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance) glfwGetInstanceProcAddress(NULL, "vkCreateInstance"); @endcode @@ -122,7 +122,7 @@ PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance) Once you have created an instance, you can load from it all other Vulkan core functions and functions from any instance extensions you enabled. -@code +@code{.c} PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice) glfwGetInstanceProcAddress(instance, "vkCreateDevice"); @endcode @@ -137,7 +137,7 @@ Vulkan also provides `vkGetDeviceProcAddr` for loading device-specific versions of Vulkan function. This function can be retrieved from an instance with @ref glfwGetInstanceProcAddress. -@code +@code{.c} PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) glfwGetInstanceProcAddress(instance, "vkGetDeviceProcAddr"); @endcode @@ -156,7 +156,7 @@ GLFW requires to create Vulkan surfaces. To query the instance extensions required, call @ref glfwGetRequiredInstanceExtensions. -@code +@code{.c} uint32_t count; const char** extensions = glfwGetRequiredInstanceExtensions(&count); @endcode @@ -174,7 +174,7 @@ If successful the returned array will always include `VK_KHR_surface`, so if you don't require any additional extensions you can pass this list directly to the `VkInstanceCreateInfo` struct. -@code +@code{.c} VkInstanceCreateInfo ici; memset(&ici, 0, sizeof(ici)); @@ -203,7 +203,7 @@ To check whether a specific queue family of a physical device supports image presentation without first having to create a window and surface, call @ref glfwGetPhysicalDevicePresentationSupport. -@code +@code{.c} if (glfwGetPhysicalDevicePresentationSupport(instance, physical_device, queue_family_index)) { // Queue family supports image presentation @@ -221,7 +221,7 @@ Unless you will be using OpenGL or OpenGL ES with the same window as Vulkan, there is no need to create a context. You can disable context creation with the [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint. -@code +@code{.c} glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL); @endcode @@ -234,7 +234,7 @@ See @ref context_less for more information. You can create a Vulkan surface (as defined by the `VK_KHR_surface` extension) for a GLFW window with @ref glfwCreateWindowSurface. -@code +@code{.c} VkSurfaceKHR surface; VkResult err = glfwCreateWindowSurface(instance, window, NULL, &surface); if (err) diff --git a/docs/window.dox b/docs/window.dox index 568c388f..9e19808d 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -32,7 +32,7 @@ A window and its OpenGL or OpenGL ES context are created with @ref glfwCreateWindow, which returns a handle to the created window object. For example, this creates a 640 by 480 windowed mode window: -@code +@code{.c} GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); @endcode @@ -50,7 +50,7 @@ To create a full screen window, you need to specify which monitor the window should use. In most cases, the user's primary monitor is a good choice. For more information about retrieving monitors, see @ref monitor_monitors. -@code +@code{.c} GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL); @endcode @@ -101,7 +101,7 @@ switching much smoother. This is sometimes called _windowed full screen_ or _borderless full screen_ window and counts as a full screen window. To create such a window, request the current video mode. -@code +@code{.c} const GLFWvidmode* mode = glfwGetVideoMode(monitor); glfwWindowHint(GLFW_RED_BITS, mode->redBits); @@ -114,7 +114,7 @@ GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "My Title", mon This also works for windowed mode windows that are made full screen. -@code +@code{.c} const GLFWvidmode* mode = glfwGetVideoMode(monitor); glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); @@ -129,7 +129,7 @@ make windowed full screen, you need to have saved the desktop resolution before. When a window is no longer needed, destroy it with @ref glfwDestroyWindow. -@code +@code{.c} glfwDestroyWindow(window); @endcode @@ -598,7 +598,7 @@ The current state of the close flag is returned by @ref glfwWindowShouldClose and can be set or cleared directly with @ref glfwSetWindowShouldClose. A common pattern is to use the close flag as a main loop condition. -@code +@code{.c} while (!glfwWindowShouldClose(window)) { render(window); @@ -611,7 +611,7 @@ while (!glfwWindowShouldClose(window)) If you wish to be notified when the user attempts to close a window, set a close callback. -@code +@code{.c} glfwSetWindowCloseCallback(window, window_close_callback); @endcode @@ -619,7 +619,7 @@ The callback function is called directly _after_ the close flag has been set. It can be used for example to filter close requests and clear the close flag again unless certain conditions are met. -@code +@code{.c} void window_close_callback(GLFWwindow* window) { if (!time_to_close) @@ -635,7 +635,7 @@ mode windows, this sets the size, in [screen coordinates](@ref coordinate_systems) of the _content area_ or _content area_ of the window. The window system may impose limits on window size. -@code +@code{.c} glfwSetWindowSize(window, 640, 480); @endcode @@ -647,14 +647,14 @@ resolution of the set video mode. If you wish to be notified when a window is resized, whether by the user, the system or your own code, set a size callback. -@code +@code{.c} glfwSetWindowSizeCallback(window, window_size_callback); @endcode The callback function receives the new size, in screen coordinates, of the content area of the window when the window is resized. -@code +@code{.c} void window_size_callback(GLFWwindow* window, int width, int height) { } @@ -663,7 +663,7 @@ void window_size_callback(GLFWwindow* window, int width, int height) There is also @ref glfwGetWindowSize for directly retrieving the current size of a window. -@code +@code{.c} int width, height; glfwGetWindowSize(window, &width, &height); @endcode @@ -677,7 +677,7 @@ The above functions work with the size of the content area, but decorated windows typically have title bars and window frames around this rectangle. You can retrieve the extents of these with @ref glfwGetWindowFrameSize. -@code +@code{.c} int left, top, right, bottom; glfwGetWindowFrameSize(window, &left, &top, &right, &bottom); @endcode @@ -698,14 +698,14 @@ pixels, of the framebuffer of a window. If you wish to be notified when the framebuffer of a window is resized, whether by the user or the system, set a size callback. -@code +@code{.c} glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); @endcode The callback function receives the new size of the framebuffer when it is resized, which can for example be used to update the OpenGL viewport. -@code +@code{.c} void framebuffer_size_callback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); @@ -715,7 +715,7 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height) There is also @ref glfwGetFramebufferSize for directly retrieving the current size of the framebuffer of a window. -@code +@code{.c} int width, height; glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); @@ -730,7 +730,7 @@ example if the window is dragged between a regular monitor and a high-DPI one. The content scale for a window can be retrieved with @ref glfwGetWindowContentScale. -@code +@code{.c} float xscale, yscale; glfwGetWindowContentScale(window, &xscale, &yscale); @endcode @@ -750,13 +750,13 @@ If you wish to be notified when the content scale of a window changes, whether because of a system setting change or because it was moved to a monitor with a different scale, set a content scale callback. -@code +@code{.c} glfwSetWindowContentScaleCallback(window, window_content_scale_callback); @endcode The callback function receives the new content scale of the window. -@code +@code{.c} void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale) { set_interface_scale(xscale, yscale); @@ -777,14 +777,14 @@ be enforced with @ref glfwSetWindowSizeLimits. The user may resize the window to any size and aspect ratio within the specified limits, unless the aspect ratio is also set. -@code +@code{.c} glfwSetWindowSizeLimits(window, 200, 200, 400, 400); @endcode To specify only a minimum size or only a maximum one, set the other pair to `GLFW_DONT_CARE`. -@code +@code{.c} glfwSetWindowSizeLimits(window, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE); @endcode @@ -795,7 +795,7 @@ with @ref glfwSetWindowAspectRatio. The user may resize the window freely unless size limits are also set, but the size will be constrained to maintain the aspect ratio. -@code +@code{.c} glfwSetWindowAspectRatio(window, 16, 9); @endcode @@ -803,7 +803,7 @@ The aspect ratio is specified as a numerator and denominator, corresponding to the width and height, respectively. If you want a window to maintain its current aspect ratio, use its current size as the ratio. -@code +@code{.c} int width, height; glfwGetWindowSize(window, &width, &height); glfwSetWindowAspectRatio(window, width, height); @@ -824,7 +824,7 @@ This is most often the right choice. If you need to create a window at a specific position, you can set the desired position with the @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints. -@code +@code{.c} glfwWindowHint(GLFW_POSITION_X, 70); glfwWindowHint(GLFW_POSITION_Y, 83); @endcode @@ -836,21 +836,21 @@ glfwSetWindowPos. This moves the window so that the upper-left corner of its content area has the specified [screen coordinates](@ref coordinate_systems). The window system may put limitations on window placement. -@code +@code{.c} glfwSetWindowPos(window, 100, 100); @endcode If you wish to be notified when a window is moved, whether by the user, the system or your own code, set a position callback. -@code +@code{.c} glfwSetWindowPosCallback(window, window_pos_callback); @endcode The callback function receives the new position, in screen coordinates, of the upper-left corner of the content area when the window is moved. -@code +@code{.c} void window_pos_callback(GLFWwindow* window, int xpos, int ypos) { } @@ -859,7 +859,7 @@ void window_pos_callback(GLFWwindow* window, int xpos, int ypos) There is also @ref glfwGetWindowPos for directly retrieving the current position of the content area of the window. -@code +@code{.c} int xpos, ypos; glfwGetWindowPos(window, &xpos, &ypos); @endcode @@ -871,7 +871,7 @@ All GLFW windows have a title, although undecorated or full screen windows may not display it or only display it in a task bar or similar interface. You can set a UTF-8 encoded window title with @ref glfwSetWindowTitle. -@code +@code{.c} glfwSetWindowTitle(window, "My Window"); @endcode @@ -881,13 +881,13 @@ to keep it around. As long as your source file is encoded as UTF-8, you can use any Unicode characters directly in the source. -@code +@code{.c} glfwSetWindowTitle(window, "ラストエグザイル"); @endcode If you are using C++11 or C11, you can use a UTF-8 string literal. -@code +@code{.c} glfwSetWindowTitle(window, u8"This is always a UTF-8 string"); @endcode @@ -897,7 +897,7 @@ glfwSetWindowTitle(window, u8"This is always a UTF-8 string"); Decorated windows have icons on some platforms. You can set this icon by specifying a list of candidate images with @ref glfwSetWindowIcon. -@code +@code{.c} GLFWimage images[2]; images[0] = load_icon("my_icon.png"); images[1] = load_icon("my_icon_small.png"); @@ -911,7 +911,7 @@ sequential rows, starting from the top-left corner. To revert to the default window icon, pass in an empty image array. -@code +@code{.c} glfwSetWindowIcon(window, 0, NULL); @endcode @@ -921,7 +921,7 @@ glfwSetWindowIcon(window, 0, NULL); Full screen windows are associated with a specific monitor. You can get the handle for this monitor with @ref glfwGetWindowMonitor. -@code +@code{.c} GLFWmonitor* monitor = glfwGetWindowMonitor(window); @endcode @@ -935,7 +935,7 @@ with @ref glfwSetWindowMonitor. When making a window full screen on the same or on a different monitor, specify the desired monitor, resolution and refresh rate. The position arguments are ignored. -@code +@code{.c} const GLFWvidmode* mode = glfwGetVideoMode(monitor); glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); @@ -944,7 +944,7 @@ glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->ref When making the window windowed, specify the desired position and size. The refresh rate argument is ignored. -@code +@code{.c} glfwSetWindowMonitor(window, NULL, xpos, ypos, width, height, 0); @endcode @@ -958,7 +958,7 @@ before making it full screen and then pass them in as above. Windows can be iconified (i.e. minimized) with @ref glfwIconifyWindow. -@code +@code{.c} glfwIconifyWindow(window); @endcode @@ -968,7 +968,7 @@ is restored until the user or application restores the window. Iconified windows can be restored with @ref glfwRestoreWindow. This function also restores windows from maximization. -@code +@code{.c} glfwRestoreWindow(window); @endcode @@ -978,13 +978,13 @@ monitor as well. If you wish to be notified when a window is iconified or restored, whether by the user, system or your own code, set an iconify callback. -@code +@code{.c} glfwSetWindowIconifyCallback(window, window_iconify_callback); @endcode The callback function receives changes in the iconification state of the window. -@code +@code{.c} void window_iconify_callback(GLFWwindow* window, int iconified) { if (iconified) @@ -1000,7 +1000,7 @@ void window_iconify_callback(GLFWwindow* window, int iconified) You can also get the current iconification state with @ref glfwGetWindowAttrib. -@code +@code{.c} int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); @endcode @@ -1009,7 +1009,7 @@ int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); Windows can be maximized (i.e. zoomed) with @ref glfwMaximizeWindow. -@code +@code{.c} glfwMaximizeWindow(window); @endcode @@ -1019,20 +1019,20 @@ function does nothing. Maximized windows can be restored with @ref glfwRestoreWindow. This function also restores windows from iconification. -@code +@code{.c} glfwRestoreWindow(window); @endcode If you wish to be notified when a window is maximized or restored, whether by the user, system or your own code, set a maximize callback. -@code +@code{.c} glfwSetWindowMaximizeCallback(window, window_maximize_callback); @endcode The callback function receives changes in the maximization state of the window. -@code +@code{.c} void window_maximize_callback(GLFWwindow* window, int maximized) { if (maximized) @@ -1048,7 +1048,7 @@ void window_maximize_callback(GLFWwindow* window, int maximized) You can also get the current maximization state with @ref glfwGetWindowAttrib. -@code +@code{.c} int maximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED); @endcode @@ -1056,7 +1056,7 @@ By default, newly created windows are not maximized. You can change this behavior by setting the [GLFW_MAXIMIZED](@ref GLFW_MAXIMIZED_hint) window hint before creating the window. -@code +@code{.c} glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); @endcode @@ -1065,7 +1065,7 @@ glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); Windowed mode windows can be hidden with @ref glfwHideWindow. -@code +@code{.c} glfwHideWindow(window); @endcode @@ -1075,7 +1075,7 @@ and calling @ref glfwHideWindow on a full screen window does nothing. Hidden windows can be shown with @ref glfwShowWindow. -@code +@code{.c} glfwShowWindow(window); @endcode @@ -1086,7 +1086,7 @@ existing window with @ref glfwSetWindowAttrib. You can also get the current visibility state with @ref glfwGetWindowAttrib. -@code +@code{.c} int visible = glfwGetWindowAttrib(window, GLFW_VISIBLE); @endcode @@ -1094,7 +1094,7 @@ By default, newly created windows are visible. You can change this behavior by setting the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint before creating the window. -@code +@code{.c} glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); @endcode @@ -1108,7 +1108,7 @@ example moving it to a specific location. Windows can be given input focus and brought to the front with @ref glfwFocusWindow. -@code +@code{.c} glfwFocusWindow(window); @endcode @@ -1119,13 +1119,13 @@ to the top. For a less disruptive way of getting the user's attention, see If you wish to be notified when a window gains or loses input focus, whether by the user, system or your own code, set a focus callback. -@code +@code{.c} glfwSetWindowFocusCallback(window, window_focus_callback); @endcode The callback function receives changes in the input focus state of the window. -@code +@code{.c} void window_focus_callback(GLFWwindow* window, int focused) { if (focused) @@ -1141,7 +1141,7 @@ void window_focus_callback(GLFWwindow* window, int focused) You can also get the current input focus state with @ref glfwGetWindowAttrib. -@code +@code{.c} int focused = glfwGetWindowAttrib(window, GLFW_FOCUSED); @endcode @@ -1149,7 +1149,7 @@ By default, newly created windows are given input focus. You can change this behavior by setting the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) window hint before creating the window. -@code +@code{.c} glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE); @endcode @@ -1159,7 +1159,7 @@ glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE); If you wish to notify the user of an event without interrupting, you can request attention with @ref glfwRequestWindowAttention. -@code +@code{.c} glfwRequestWindowAttention(window); @endcode @@ -1173,14 +1173,14 @@ attention, the system will automatically end the request. If you wish to be notified when the contents of a window is damaged and needs to be refreshed, set a window refresh callback. -@code +@code{.c} glfwSetWindowRefreshCallback(m_handle, window_refresh_callback); @endcode The callback function is called when the contents of the window needs to be refreshed. -@code +@code{.c} void window_refresh_callback(GLFWwindow* window) { draw_editor_ui(window); @@ -1207,7 +1207,7 @@ Window framebuffers can be made transparent on a per-pixel per-frame basis with the [GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) window hint. -@code +@code{.c} glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); @endcode @@ -1220,7 +1220,7 @@ with the [GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib) window attribute. -@code +@code{.c} if (glfwGetWindowAttrib(window, GLFW_TRANSPARENT_FRAMEBUFFER)) { // window framebuffer is currently transparent @@ -1232,7 +1232,7 @@ GLFW comes with an example that enabled framebuffer transparency called `gears`. The opacity of the whole window, including any decorations, can be set with @ref glfwSetWindowOpacity. -@code +@code{.c} glfwSetWindowOpacity(window, 0.5f); @endcode @@ -1242,7 +1242,7 @@ opacity value for newly created windows is 1. The current opacity of a window can be queried with @ref glfwGetWindowOpacity. -@code +@code{.c} float opacity = glfwGetWindowOpacity(window); @endcode @@ -1265,7 +1265,7 @@ interaction, (e.g. whether it has input focus), while others reflect inherent properties of the window (e.g. what kind of border it has). Some are related to the window and others to its OpenGL or OpenGL ES context. -@code +@code{.c} if (glfwGetWindowAttrib(window, GLFW_FOCUSED)) { // window has input focus @@ -1279,7 +1279,7 @@ The [GLFW_DECORATED](@ref GLFW_DECORATED_attrib), [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib) window attributes can be changed with @ref glfwSetWindowAttrib. -@code +@code{.c} glfwSetWindowAttrib(window, GLFW_RESIZABLE, GLFW_FALSE); @endcode @@ -1465,7 +1465,7 @@ When the entire frame has been rendered, it is time to swap the back and the front buffers in order to display what has been rendered and begin rendering a new frame. This is done with @ref glfwSwapBuffers. -@code +@code{.c} glfwSwapBuffers(window); @endcode @@ -1474,7 +1474,7 @@ function @ref glfwSwapInterval it is possible to select the minimum number of monitor refreshes the driver should wait from the time @ref glfwSwapBuffers was called before swapping the buffers: -@code +@code{.c} glfwSwapInterval(1); @endcode From e3e41ba339c4de38ed26349789695f53307d2a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 14 Feb 2024 18:11:28 +0100 Subject: [PATCH 077/137] Move to Doxygen 1.9.8 and later --- CMakeLists.txt | 12 +----------- docs/CMakeLists.txt | 31 +++++++++++++++++++++---------- docs/DoxygenLayout.xml | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e43fe21..f0904b7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,11 +59,6 @@ list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules") find_package(Threads REQUIRED) -if (GLFW_BUILD_DOCS) - set(DOXYGEN_SKIP_DOT TRUE) - find_package(Doxygen) -endif() - #-------------------------------------------------------------------- # Report backend selection #-------------------------------------------------------------------- @@ -134,7 +129,7 @@ if (GLFW_BUILD_TESTS) add_subdirectory(tests) endif() -if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS) +if (GLFW_BUILD_DOCS) add_subdirectory(docs) endif() @@ -156,11 +151,6 @@ if (GLFW_INSTALL) install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") - if (DOXYGEN_FOUND AND 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 diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 79cad560..d6e9b6eb 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -31,16 +31,27 @@ foreach(file IN LISTS source_files) string(APPEND GLFW_DOXYGEN_INPUT " \\\n\"${CMAKE_CURRENT_SOURCE_DIR}/${file}\"") endforeach() -configure_file(Doxyfile.in Doxyfile @ONLY) +set(DOXYGEN_SKIP_DOT TRUE) +find_package(Doxygen) -add_custom_command(OUTPUT "html/index.html" - COMMAND "${DOXYGEN_EXECUTABLE}" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" - MAIN_DEPENDENCY Doxyfile - DEPENDS ${header_paths} ${source_files} ${extra_files} - COMMENT "Generating HTML documentation" - VERBATIM) +if (NOT DOXYGEN_FOUND OR DOXYGEN_VERSION VERSION_LESS "1.9.8") + message(STATUS "Documentation generation requires Doxygen 1.9.8 or later") +else() + configure_file(Doxyfile.in Doxyfile @ONLY) + add_custom_command(OUTPUT "html/index.html" + COMMAND "${DOXYGEN_EXECUTABLE}" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + MAIN_DEPENDENCY Doxyfile + DEPENDS ${header_paths} ${source_files} ${extra_files} + COMMENT "Generating HTML documentation" + VERBATIM) -add_custom_target(docs ALL SOURCES "html/index.html") -set_target_properties(docs PROPERTIES FOLDER "GLFW3") + add_custom_target(docs ALL SOURCES "html/index.html") + set_target_properties(docs PROPERTIES FOLDER "GLFW3") + + if (GLFW_INSTALL) + install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html" + DESTINATION "${CMAKE_INSTALL_DOCDIR}") + endif() +endif() diff --git a/docs/DoxygenLayout.xml b/docs/DoxygenLayout.xml index ab971721..66cb87fd 100644 --- a/docs/DoxygenLayout.xml +++ b/docs/DoxygenLayout.xml @@ -5,7 +5,7 @@ - + From 3e73a5c76cf4a5e21a5107e8583130ca4f3338af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Feb 2024 20:20:56 +0100 Subject: [PATCH 078/137] Rename Doxygen files to Markdown --- .editorconfig | 2 +- docs/CMakeLists.txt | 28 ++++++++++++++-------------- docs/CONTRIBUTING.md | 4 ++-- docs/{build.dox => build.md} | 3 --- docs/{compat.dox => compat.md} | 3 --- docs/{compile.dox => compile.md} | 3 --- docs/{context.dox => context.md} | 3 --- docs/{input.dox => input.md} | 3 --- docs/{internal.dox => internal.md} | 3 --- docs/{intro.dox => intro.md} | 3 --- docs/{main.dox => main.md} | 3 --- docs/{monitor.dox => monitor.md} | 3 --- docs/{moving.dox => moving.md} | 3 --- docs/{news.dox => news.md} | 3 --- docs/{quick.dox => quick.md} | 3 --- docs/{vulkan.dox => vulkan.md} | 3 --- docs/{window.dox => window.md} | 3 --- 17 files changed, 17 insertions(+), 59 deletions(-) rename docs/{build.dox => build.md} (99%) rename docs/{compat.dox => compat.md} (99%) rename docs/{compile.dox => compile.md} (99%) rename docs/{context.dox => context.md} (99%) rename docs/{input.dox => input.md} (99%) rename docs/{internal.dox => internal.md} (99%) rename docs/{intro.dox => intro.md} (99%) rename docs/{main.dox => main.md} (99%) rename docs/{monitor.dox => monitor.md} (99%) rename docs/{moving.dox => moving.md} (99%) rename docs/{news.dox => news.md} (99%) rename docs/{quick.dox => quick.md} (99%) rename docs/{vulkan.dox => vulkan.md} (99%) rename docs/{window.dox => window.md} (99%) diff --git a/.editorconfig b/.editorconfig index d5e0290f..2b44e7b2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -28,7 +28,7 @@ indent_size = 4 indent_style = space indent_size = 4 -[*.{dox,md}] +[*.{md}] indent_style = space indent_size = 4 trim_trailing_whitespace = false diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index d6e9b6eb..50522173 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -2,20 +2,20 @@ # NOTE: The order of this list determines the order of items in the Guides # (i.e. Pages) list in the generated documentation set(source_files - main.dox - news.dox - quick.dox - moving.dox - compile.dox - build.dox - intro.dox - context.dox - monitor.dox - window.dox - input.dox - vulkan.dox - compat.dox - internal.dox) + main.md + news.md + quick.md + moving.md + compile.md + build.md + intro.md + context.md + monitor.md + window.md + input.md + vulkan.md + compat.md + internal.md) set(extra_files DoxygenLayout.xml header.html footer.html extra.css spaces.svg) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 17bb85e6..73ba01e3 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -357,7 +357,7 @@ feature. In addition to the code, a complete feature includes: - Change log entry in `README.md`, listing all new symbols -- News page entry in `docs/news.dox`, briefly describing the feature +- News page entry in `docs/news.md`, briefly describing the feature - Guide documentation, with minimal examples, in the relevant guide in the `docs` folder - Reference documentation, with all applicable tags - Cross-references and mentions in appropriate places @@ -373,7 +373,7 @@ If it adds a new monitor property, support for it must be added to If it adds a new OpenGL, OpenGL ES or Vulkan option or extension, support for it must be added to `tests/glfwinfo.c` and the behavior of the library when -the extension is missing documented in `docs/compat.dox`. +the extension is missing documented in `docs/compat.md`. If you haven't already, read the excellent article [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/). diff --git a/docs/build.dox b/docs/build.md similarity index 99% rename from docs/build.dox rename to docs/build.md index 3d9ca845..512a17bf 100644 --- a/docs/build.dox +++ b/docs/build.md @@ -1,5 +1,3 @@ -/*! - @page build_guide Building applications @tableofcontents @@ -335,4 +333,3 @@ against it from the command-line. @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. -*/ diff --git a/docs/compat.dox b/docs/compat.md similarity index 99% rename from docs/compat.dox rename to docs/compat.md index 66a92614..e590ccfe 100644 --- a/docs/compat.dox +++ b/docs/compat.md @@ -1,5 +1,3 @@ -/*! - @page compat_guide Standards conformance @tableofcontents @@ -285,4 +283,3 @@ surfaces on Wayland. If any of these extensions are not available, @ref glfwGetRequiredInstanceExtensions will return an empty list and window surface creation will fail. -*/ diff --git a/docs/compile.dox b/docs/compile.md similarity index 99% rename from docs/compile.dox rename to docs/compile.md index 0c33ff0f..65a82618 100644 --- a/docs/compile.dox +++ b/docs/compile.md @@ -1,5 +1,3 @@ -/*! - @page compile_guide Compiling GLFW @tableofcontents @@ -368,4 +366,3 @@ _GLFW_GLESV2_LIBRARY. Otherwise, GLFW will use the built-in default names. GLFW. If you define any of these in your build files, make sure they are not applied to the GLFW sources. -*/ diff --git a/docs/context.dox b/docs/context.md similarity index 99% rename from docs/context.dox rename to docs/context.md index 67ff7583..eb1b2434 100644 --- a/docs/context.dox +++ b/docs/context.md @@ -1,5 +1,3 @@ -/*! - @page context_guide Context guide @tableofcontents @@ -340,4 +338,3 @@ void some_function(void) } @endcode -*/ diff --git a/docs/input.dox b/docs/input.md similarity index 99% rename from docs/input.dox rename to docs/input.md index f3ccbb2b..4c51e025 100644 --- a/docs/input.dox +++ b/docs/input.md @@ -1,5 +1,3 @@ -/*! - @page input_guide Input guide @tableofcontents @@ -980,4 +978,3 @@ The path array and its strings are only valid until the file drop callback returns, as they may have been generated specifically for that event. You need to make a deep copy of the array if you want to keep the paths. -*/ diff --git a/docs/internal.dox b/docs/internal.md similarity index 99% rename from docs/internal.dox rename to docs/internal.md index 69227568..ff281e46 100644 --- a/docs/internal.dox +++ b/docs/internal.md @@ -1,5 +1,3 @@ -/*! - @page internals_guide Internal structure @tableofcontents @@ -120,4 +118,3 @@ with a leading underscore. Examples: `_GLFW_WIN32`, `_GLFW_BUILD_DLL` -*/ diff --git a/docs/intro.dox b/docs/intro.md similarity index 99% rename from docs/intro.dox rename to docs/intro.md index 7a47e034..085cdd7e 100644 --- a/docs/intro.dox +++ b/docs/intro.md @@ -1,5 +1,3 @@ -/*! - @page intro_guide Introduction to the API @tableofcontents @@ -635,4 +633,3 @@ result in a version string like this: 3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic @endcode -*/ diff --git a/docs/main.dox b/docs/main.md similarity index 99% rename from docs/main.dox rename to docs/main.md index 995c2f56..53faeea9 100644 --- a/docs/main.dox +++ b/docs/main.md @@ -1,5 +1,3 @@ -/*! - @mainpage notitle @section main_intro Introduction @@ -43,4 +41,3 @@ This documentation was generated with Doxygen. The sources for it are available in both the [source distribution](https://www.glfw.org/download.html) and [GitHub repository](https://github.com/glfw/glfw). -*/ diff --git a/docs/monitor.dox b/docs/monitor.md similarity index 99% rename from docs/monitor.dox rename to docs/monitor.md index c94ab01a..5aa5ed7f 100644 --- a/docs/monitor.dox +++ b/docs/monitor.md @@ -1,5 +1,3 @@ -/*! - @page monitor_guide Monitor guide @tableofcontents @@ -265,4 +263,3 @@ hardware gamma correction, which today is typically an approximation of sRGB gamma. This means that setting a perfectly linear ramp, or gamma 1.0, will produce the default (usually sRGB-like) behavior. -*/ diff --git a/docs/moving.dox b/docs/moving.md similarity index 99% rename from docs/moving.dox rename to docs/moving.md index 51ca4c4a..fe4f30b8 100644 --- a/docs/moving.dox +++ b/docs/moving.md @@ -1,5 +1,3 @@ -/*! - @page moving_guide Moving from GLFW 2 to 3 @tableofcontents @@ -510,4 +508,3 @@ tessellation functions, see for example | `GLFW_KEY_RALT` | `GLFW_KEY_RIGHT_ALT` | | | `GLFW_KEY_RSUPER` | `GLFW_KEY_RIGHT_SUPER` | | -*/ diff --git a/docs/news.dox b/docs/news.md similarity index 99% rename from docs/news.dox rename to docs/news.md index 2a546bc6..b316b8db 100644 --- a/docs/news.dox +++ b/docs/news.md @@ -1,5 +1,3 @@ -/*! - @page news Release notes @tableofcontents @@ -298,4 +296,3 @@ then GLFW will fail to initialize. - [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) -*/ diff --git a/docs/quick.dox b/docs/quick.md similarity index 99% rename from docs/quick.dox rename to docs/quick.md index 037f11e2..03688d53 100644 --- a/docs/quick.dox +++ b/docs/quick.md @@ -1,5 +1,3 @@ -/*! - @page quick_guide Getting started @tableofcontents @@ -364,4 +362,3 @@ environment you are using and is best explained by the documentation for that environment. To learn about the details that are specific to GLFW, see @ref build_guide. -*/ diff --git a/docs/vulkan.dox b/docs/vulkan.md similarity index 99% rename from docs/vulkan.dox rename to docs/vulkan.md index 167f3456..9208c006 100644 --- a/docs/vulkan.dox +++ b/docs/vulkan.md @@ -1,5 +1,3 @@ -/*! - @page vulkan_guide Vulkan guide @tableofcontents @@ -250,4 +248,3 @@ created. It is your responsibility to destroy the surface. GLFW does not destroy it for you. Call `vkDestroySurfaceKHR` function from the same extension to destroy it. -*/ diff --git a/docs/window.dox b/docs/window.md similarity index 99% rename from docs/window.dox rename to docs/window.md index 9e19808d..89883711 100644 --- a/docs/window.dox +++ b/docs/window.md @@ -1,5 +1,3 @@ -/*! - @page window_guide Window guide @tableofcontents @@ -1495,4 +1493,3 @@ which allows the driver to swap immediately even if a frame arrives a little bit late. This trades the risk of visible tears for greater framerate stability. You can check for these extensions with @ref glfwExtensionSupported. -*/ From 611099f745c7ceecba3023ed963866620e0efe58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Feb 2024 20:45:29 +0100 Subject: [PATCH 079/137] Convert Doxygen headings to Markdown --- docs/build.md | 20 ++++++------ docs/compat.md | 16 +++++----- docs/compile.md | 30 +++++++++--------- docs/context.md | 28 ++++++++--------- docs/input.md | 60 +++++++++++++++++------------------ docs/internal.md | 16 +++++----- docs/intro.md | 48 ++++++++++++++-------------- docs/main.md | 4 +-- docs/monitor.md | 26 +++++++-------- docs/moving.md | 58 +++++++++++++++++----------------- docs/news.md | 68 +++++++++++++++++++-------------------- docs/quick.md | 28 ++++++++--------- docs/vulkan.md | 18 +++++------ docs/window.md | 82 ++++++++++++++++++++++++------------------------ 14 files changed, 250 insertions(+), 252 deletions(-) diff --git a/docs/build.md b/docs/build.md index 512a17bf..43f351d1 100644 --- a/docs/build.md +++ b/docs/build.md @@ -1,4 +1,4 @@ -@page build_guide Building applications +# Building applications {#build_guide} @tableofcontents @@ -14,7 +14,7 @@ and linking process should be explained in your C programming material and in the documentation for your development environment. -@section build_include Including the GLFW header file +## Including the GLFW header file {#build_include} You should include the GLFW header in the source files where you use OpenGL or GLFW. @@ -66,7 +66,7 @@ headers in any order. @endcode -@subsection build_macros GLFW header option macros +### GLFW header option macros {#build_macros} These macros may be defined before the inclusion of the GLFW header and affect its behavior. @@ -140,7 +140,7 @@ If your build includes GLFW and you define any these in your build files, make sure they are not applied to the GLFW sources. -@section build_link Link with the right libraries +## Link with the right libraries {#build_link} GLFW is essentially a wrapper of various platform-specific APIs and therefore needs to link against many different system libraries. If you are using GLFW as @@ -158,7 +158,7 @@ A good general introduction to linking is David Drysdale. -@subsection build_link_win32 With MinGW or Visual C++ on Windows +### With MinGW or Visual C++ on Windows {#build_link_win32} The static version of the GLFW library is named `glfw3`. When using this version, it is also necessary to link with some libraries that GLFW uses. @@ -174,7 +174,7 @@ 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. -@subsection build_link_cmake_source With CMake and GLFW source +### With CMake and GLFW source {#build_link_cmake_source} This section is about using CMake to compile and link GLFW along with your application. If you want to use an installed binary instead, see @ref @@ -220,7 +220,7 @@ 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 +### With CMake and installed GLFW binaries {#build_link_cmake_package} This section is about using CMake to link GLFW after it has been built and installed. If you want to build it along with your application instead, see @@ -259,7 +259,7 @@ target_link_libraries(myapp OpenGL::GL) @endcode -@subsection build_link_pkgconfig With makefiles and pkg-config on Unix +### With makefiles and pkg-config on Unix {#build_link_pkgconfig} GLFW supports [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/), and the `glfw3.pc` pkg-config file is generated when the GLFW library is built @@ -300,7 +300,7 @@ cc $(pkg-config --cflags glfw3 gl) -o myprog myprog.c $(pkg-config --libs glfw3 @endcode -@subsection build_link_xcode With Xcode on macOS +### With Xcode on macOS {#build_link_xcode} If you are using the dynamic library version of GLFW, add it to the project dependencies. @@ -310,7 +310,7 @@ 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 +### With command-line on macOS {#build_link_osx} It is recommended that you use [pkg-config](@ref build_link_pkgconfig) when building from the command line on macOS. That way you will get any new diff --git a/docs/compat.md b/docs/compat.md index e590ccfe..0d363a79 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -1,4 +1,4 @@ -@page compat_guide Standards conformance +# Standards conformance {#compat_guide} @tableofcontents @@ -13,7 +13,7 @@ part of this information may change in future versions of GLFW and that will not be considered a breaking API change. -@section compat_x11 X11 extensions, protocols and IPC standards +## X11 extensions, protocols and IPC standards {#compat_x11} As GLFW uses Xlib directly, without any intervening toolkit library, it has sole responsibility for interacting well with the many and @@ -91,7 +91,7 @@ conventions, the `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR` and legacy images. -@section compat_wayland Wayland protocols and IPC standards +## Wayland protocols and IPC standards {#compat_wayland} As GLFW uses libwayland directly, without any intervening toolkit library, it has sole responsibility for interacting well with every compositor in use on @@ -144,7 +144,7 @@ to implement window focus and attention requests. If the running compositor does not support this protocol, window focus and attention requests do nothing. -@section compat_glx GLX extensions +## GLX extensions {#compat_glx} The GLX API is the default API used to create OpenGL contexts on Unix-like systems using the X Window System. @@ -184,7 +184,7 @@ extensions to provide support for sRGB framebuffers. Where both of these extensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect. -@section compat_wgl WGL extensions +## WGL extensions {#compat_wgl} The WGL API is used to create OpenGL contexts on Microsoft Windows and other implementations of the Win32 API, such as Wine. @@ -225,7 +225,7 @@ extensions to provide support for sRGB framebuffers. When both of these extensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect. -@section compat_osx OpenGL on macOS +## OpenGL on macOS {#compat_osx} Support for OpenGL 3.2 and above was introduced with OS X 10.7 and even then only forward-compatible, core profile contexts are supported. Support for @@ -247,7 +247,7 @@ a non-default value will cause @ref glfwCreateWindow to fail and the `GLFW_CONTEXT_DEBUG` hint is ignored. -@section compat_vulkan Vulkan loader and API +## Vulkan loader and API {#compat_vulkan} By default, GLFW uses the standard system-wide Vulkan loader to access the Vulkan API on all platforms except macOS. This is installed by both graphics @@ -257,7 +257,7 @@ all other Vulkan-related functions will fail with an @ref GLFW_API_UNAVAILABLE error. -@section compat_wsi Vulkan WSI extensions +## Vulkan WSI extensions {#compat_wsi} The Vulkan WSI extensions are used to create Vulkan surfaces for GLFW windows on all supported platforms. diff --git a/docs/compile.md b/docs/compile.md index 65a82618..cc3c8991 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -1,4 +1,4 @@ -@page compile_guide Compiling GLFW +# Compiling GLFW {#compile_guide} @tableofcontents @@ -8,7 +8,7 @@ build applications that use GLFW, see @ref build_guide. GLFW uses some C99 features and does not support Visual Studio 2012 and earlier. -@section compile_cmake Using CMake +## Using CMake {#compile_cmake} GLFW behaves like most other libraries that use CMake so this guide mostly describes the standard configure, generate and compile sequence. If you are already @@ -33,14 +33,14 @@ that includes everything in this guide not specific to GLFW. It may be a useful companion to this one. -@subsection compile_deps Installing dependencies +### Installing dependencies {#compile_deps} The C/C++ development environments in Visual Studio, Xcode and MinGW come with all necessary dependencies for compiling GLFW, but on Unix-like systems like Linux and FreeBSD you will need a few extra packages. -@subsubsection compile_deps_wayland Dependencies for Wayland and X11 +#### Dependencies for Wayland and X11 {#compile_deps_wayland} By default, both the Wayland and X11 backends are enabled on Linux and other Unix-like systems (except macOS). To disable one or both of these, set the @ref GLFW_BUILD_WAYLAND @@ -85,7 +85,7 @@ pull in all other dependencies. Once you have the required dependencies, move on to @ref compile_generate. -@subsection compile_generate Generating build files with CMake +### Generating build files with CMake {#compile_generate} Once you have all necessary dependencies it is time to generate the project files or makefiles for your development environment. CMake needs two paths for @@ -107,7 +107,7 @@ A common pattern when building a single configuration is to have a build directory named `build` in the root of the source tree. -@subsubsection compile_generate_gui Generating with the CMake GUI +#### Generating with the CMake GUI {#compile_generate_gui} Start the CMake GUI and set the paths to the source and build directories described above. Then press _Configure_ and _Generate_. @@ -125,7 +125,7 @@ Once you have generated the project files or makefiles for your chosen development environment, move on to @ref compile_compile. -@subsubsection compile_generate_cli Generating with command-line CMake +#### Generating with command-line CMake {#compile_generate_cli} To make a build directory, pass the source and build directories to the `cmake` command. These can be relative or absolute paths. The build directory is @@ -163,7 +163,7 @@ Once you have generated the project files or makefiles for your chosen development environment, move on to @ref compile_compile. -@subsection compile_compile Compiling the library +### Compiling the library {#compile_compile} You should now have all required dependencies and the project files or makefiles necessary to compile GLFW. Go ahead and compile the actual GLFW library with @@ -199,7 +199,7 @@ Once the GLFW library is compiled you are ready to build your application, linking it to the GLFW library. See @ref build_guide for more information. -@section compile_options CMake options +## CMake options {#compile_options} The CMake files for GLFW provide a number of options, although not all are available on all supported platforms. Some of these are de facto standards @@ -219,7 +219,7 @@ cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON @endcode -@subsection compile_options_shared Shared CMake options +### Shared CMake options {#compile_options_shared} @anchor BUILD_SHARED_LIBS __BUILD_SHARED_LIBS__ determines whether GLFW is built as a static library or as @@ -251,7 +251,7 @@ with the library. This is enabled by default if [Doxygen](https://www.doxygen.nl/) is found by CMake during configuration. -@subsection compile_options_win32 Win32 specific CMake options +### Win32 specific CMake options {#compile_options_win32} @anchor GLFW_BUILD_WIN32 __GLFW_BUILD_WIN32__ determines whether to include support for Win32 when compiling the @@ -276,7 +276,7 @@ will not work if GLFW is built as a DLL. This is disabled by default, letting the operating system and driver decide. -@subsection compile_options_macos macOS specific CMake options +### macOS specific CMake options {#compile_options_macos} @anchor GLFW_BUILD_COCOA __GLFW_BUILD_COCOA__ determines whether to include support for Cocoa when compiling the @@ -284,7 +284,7 @@ library. This option is only available when compiling for macOS. This is enabl default. -@subsection compile_options_unix Unix-like system specific CMake options +### Unix-like system specific CMake options {#compile_options_unix} @anchor GLFW_BUILD_WAYLAND __GLFW_BUILD_WAYLAND__ determines whether to include support for Wayland when compiling @@ -297,7 +297,7 @@ library. This option is only available when compiling for Linux and other Unix- systems other than macOS. This is enabled by default. -@section compile_mingw_cross Cross-compilation with CMake and MinGW +## Cross-compilation with CMake and MinGW {#compile_mingw_cross} Both Cygwin and many Linux distributions have MinGW or MinGW-w64 packages. For example, Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages @@ -330,7 +330,7 @@ For more details see the [CMake toolchain guide](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html). -@section compile_manual Compiling GLFW manually +## Compiling GLFW manually {#compile_manual} If you wish to compile GLFW without its CMake build environment then you will have to do at least some platform-detection yourself. There are preprocessor macros for diff --git a/docs/context.md b/docs/context.md index eb1b2434..c900a8bb 100644 --- a/docs/context.md +++ b/docs/context.md @@ -1,4 +1,4 @@ -@page context_guide Context guide +# Context guide {#context_guide} @tableofcontents @@ -13,7 +13,7 @@ context. There are also guides for the other areas of the GLFW API. - @ref input_guide -@section context_object Context objects +## Context objects {#context_object} A window object encapsulates both a top-level window and an OpenGL or OpenGL ES context. It is created with @ref glfwCreateWindow and destroyed with @ref @@ -32,14 +32,14 @@ context creation by setting the [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_NO_API`. For more information, see the @ref vulkan_guide. -@subsection context_hints Context creation hints +### Context creation hints {#context_hints} There are a number of hints, specified using @ref glfwWindowHint, related to what kind of context is created. See [context related hints](@ref window_hints_ctx) in the window guide. -@subsection context_sharing Context object sharing +### Context object sharing {#context_sharing} When creating a window and its OpenGL or OpenGL ES context with @ref glfwCreateWindow, you can specify another window whose context the new one @@ -62,7 +62,7 @@ Contexts_. GLFW comes with a bare-bones object sharing example program called `sharing`. -@subsection context_offscreen Offscreen contexts +### Offscreen contexts {#context_offscreen} GLFW doesn't support creating contexts without an associated window. However, contexts with hidden windows can be created with the @@ -83,7 +83,7 @@ You should still [process events](@ref events) as long as you have at least one window, even if none of them are visible. -@subsection context_less Windows without contexts +### Windows without contexts {#context_less} You can disable context creation by setting the [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_NO_API`. @@ -92,7 +92,7 @@ Windows without contexts should not be passed to @ref glfwMakeContextCurrent or @ref glfwSwapBuffers. Doing this generates a @ref GLFW_NO_WINDOW_CONTEXT error. -@section context_current Current context +## Current context {#context_current} Before you can make OpenGL or OpenGL ES calls, you need to have a current context of the correct type. A context can only be current for a single thread @@ -122,12 +122,12 @@ error. - @ref glfwGetProcAddress -@section context_swap Buffer swapping +## Buffer swapping {#context_swap} See @ref buffer_swap in the window guide. -@section context_glext OpenGL and OpenGL ES extensions +## OpenGL and OpenGL ES extensions {#context_glext} One of the benefits of OpenGL and OpenGL ES is their extensibility. Hardware vendors may include extensions in their implementations that extend the @@ -150,7 +150,7 @@ their specifications, can be found at the [OpenGL ES Registry](https://www.khronos.org/registry/gles/). -@subsection context_glext_auto Loading extension with a loader library +### Loading extension with a loader library {#context_glext_auto} An extension loader library is the easiest and best way to access both OpenGL and OpenGL ES extensions and modern versions of the core OpenGL or OpenGL ES APIs. @@ -231,7 +231,7 @@ if (GLAD_GL_ARB_gl_spirv) @endcode -@subsection context_glext_manual Loading extensions manually +### Loading extensions manually {#context_glext_manual} __Do not use this technique__ unless it is absolutely necessary. An [extension loader library](@ref context_glext_auto) will save you a ton of @@ -246,7 +246,7 @@ This section will demonstrate manual loading of OpenGL extensions. The loading of OpenGL ES extensions is identical except for the name of the extension header. -@subsubsection context_glext_header The glext.h header +#### The glext.h header {#context_glext_header} The `glext.h` extension header is a continually updated file that defines the interfaces for all OpenGL extensions. The latest version of this can always be @@ -271,7 +271,7 @@ the GLFW header. @endcode -@subsubsection context_glext_string Checking for extensions +#### Checking for extensions {#context_glext_string} A given machine may not actually support the extension (it may have older drivers or a graphics card that lacks the necessary hardware features), so it @@ -290,7 +290,7 @@ extension is supported, @ref glfwExtensionSupported returns `GLFW_TRUE`, otherwise it returns `GLFW_FALSE`. -@subsubsection context_glext_proc Fetching function pointers +#### Fetching function pointers {#context_glext_proc} Many extensions, though not all, require the use of new OpenGL functions. These functions often do not have entry points in the client API libraries of diff --git a/docs/input.md b/docs/input.md index 4c51e025..bc5cc461 100644 --- a/docs/input.md +++ b/docs/input.md @@ -1,4 +1,4 @@ -@page input_guide Input guide +# Input guide {#input_guide} @tableofcontents @@ -27,7 +27,7 @@ out all arguments provided for every event, along with time and sequence information. -@section events Event processing +## Event processing {#events} GLFW needs to poll the window system for events both to provide input to the application and to prove to the window system that the application hasn't locked @@ -89,7 +89,7 @@ a [window size callback](@ref window_size) GLFW will call it in turn with the new size before everything returns back out of the @ref glfwSetWindowSize call. -@section input_keyboard Keyboard input +## Keyboard input {#input_keyboard} GLFW divides keyboard input into two categories; key events and character events. Key events relate to actual physical keyboard keys, whereas character @@ -101,7 +101,7 @@ may not be the case on your machine, but your users are likely not all using the same keyboard layout, input method or even operating system as you. -@subsection input_key Key input +### Key input {#input_key} If you wish to be notified when a physical key is pressed or released or when it repeats, set a key callback. @@ -201,7 +201,7 @@ The `GLFW_KEY_LAST` constant holds the highest value of any [key token](@ref keys). -@subsection input_char Text input +### Text input {#input_char} GLFW supports text input in the form of a stream of [Unicode code points](https://en.wikipedia.org/wiki/Unicode), as produced by the @@ -230,7 +230,7 @@ void character_callback(GLFWwindow* window, unsigned int codepoint) @endcode -@subsection input_key_name Key names +### Key names {#input_key_name} If you wish to refer to keys by name, you can query the keyboard layout dependent name of printable keys with @ref glfwGetKeyName. @@ -246,14 +246,14 @@ ignored. This matches the behavior of the key callback, meaning the callback arguments can always be passed unmodified to this function. -@section input_mouse Mouse input +## Mouse input {#input_mouse} Mouse input comes in many forms, including mouse motion, button presses and scrolling offsets. The cursor appearance can also be changed, either to a custom image or a standard cursor shape from the system theme. -@subsection cursor_pos Cursor position +### Cursor position {#cursor_pos} If you wish to be notified when the cursor moves over the window, set a cursor position callback. @@ -281,7 +281,7 @@ glfwGetCursorPos(window, &xpos, &ypos); @endcode -@subsection cursor_mode Cursor mode +### Cursor mode {#cursor_mode} @anchor GLFW_CURSOR The `GLFW_CURSOR` input mode provides several cursor modes for special forms of @@ -336,7 +336,7 @@ If the cursor was disabled, this will move it back to its last visible position. @anchor GLFW_RAW_MOUSE_MOTION -@subsection raw_mouse_motion Raw mouse motion +### Raw mouse motion {#raw_mouse_motion} When the cursor is disabled, raw (unscaled and unaccelerated) mouse motion can be enabled if available. @@ -360,7 +360,7 @@ If supported, raw mouse motion can be enabled or disabled per-window and at any time but it will only be provided when the cursor is disabled. -@subsection cursor_object Cursor objects +### Cursor objects {#cursor_object} GLFW supports creating both custom and system theme cursor images, encapsulated as @ref GLFWcursor objects. They are created with @ref glfwCreateCursor or @ref @@ -368,7 +368,7 @@ glfwCreateStandardCursor and destroyed with @ref glfwDestroyCursor, or @ref glfwTerminate, if any remain. -@subsubsection cursor_custom Custom cursor creation +#### Custom cursor creation {#cursor_custom} A custom cursor is created with @ref glfwCreateCursor, which returns a handle to the created cursor object. For example, this creates a 16x16 white square @@ -394,7 +394,7 @@ per channel with the red channel first. The pixels are arranged canonically as sequential rows, starting from the top-left corner. -@subsubsection cursor_standard Standard cursor creation +#### Standard cursor creation {#cursor_standard} A cursor with a [standard shape](@ref shapes) from the current system cursor theme can be created with @ref glfwCreateStandardCursor. @@ -410,7 +410,7 @@ 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 +#### Cursor destruction {#cursor_destruction} When a cursor is no longer needed, destroy it with @ref glfwDestroyCursor. @@ -423,7 +423,7 @@ that window will revert to the default cursor. This does not affect the cursor mode. All remaining cursors are destroyed when @ref glfwTerminate is called. -@subsubsection cursor_set Cursor setting +#### Cursor setting {#cursor_set} A cursor can be set as current for a window with @ref glfwSetCursor. @@ -447,7 +447,7 @@ When a cursor is destroyed, any window that has it set will revert to the default cursor. This does not affect the cursor mode. -@subsection cursor_enter Cursor enter/leave events +### Cursor enter/leave events {#cursor_enter} If you wish to be notified when the cursor enters or leaves the content area of a window, set a cursor enter/leave callback. @@ -483,7 +483,7 @@ if (glfwGetWindowAttrib(window, GLFW_HOVERED)) @endcode -@subsection input_mouse_button Mouse button input +### Mouse button input {#input_mouse_button} If you wish to be notified when a mouse button is pressed or released, set a mouse button callback. @@ -543,7 +543,7 @@ The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any [supported mouse button](@ref buttons). -@subsection scrolling Scroll input +### Scroll input {#scrolling} If you wish to be notified when the user scrolls, whether with a mouse wheel or touchpad gesture, set a scroll callback. @@ -563,7 +563,7 @@ void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) A normal mouse wheel, being vertical, provides offsets along the Y-axis. -@section joystick Joystick input +## Joystick input {#joystick} The joystick functions expose connected joysticks and controllers, with both referred to as joysticks. It supports up to sixteen joysticks, ranging from @@ -593,7 +593,7 @@ To see all the properties of all connected joysticks in real-time, run the `joysticks` test program. -@subsection joystick_axis Joystick axis states +### Joystick axis states {#joystick_axis} The positions of all axes of a joystick are returned by @ref glfwGetJoystickAxes. See the reference documentation for the lifetime of the @@ -607,7 +607,7 @@ const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_5, &count); Each element in the returned array is a value between -1.0 and 1.0. -@subsection joystick_button Joystick button states +### Joystick button states {#joystick_button} The states of all buttons of a joystick are returned by @ref glfwGetJoystickButtons. See the reference documentation for the lifetime of the @@ -625,7 +625,7 @@ glfwGetJoystickHats, the button array by default also includes all hats. See the reference documentation for @ref glfwGetJoystickButtons for details. -@subsection joystick_hat Joystick hat states +### Joystick hat states {#joystick_hat} The states of all hats are returned by @ref glfwGetJoystickHats. See the reference documentation for the lifetime of the returned array. @@ -665,7 +665,7 @@ glfwGetJoystickHats, all hats are by default also included in the button array. See the reference documentation for @ref glfwGetJoystickButtons for details. -@subsection joystick_name Joystick name +### Joystick name {#joystick_name} The human-readable, UTF-8 encoded name of a joystick is returned by @ref glfwGetJoystickName. See the reference documentation for the lifetime of the @@ -680,7 +680,7 @@ and make may have the same name. Only the [joystick ID](@ref joysticks) is guaranteed to be unique, and only until that joystick is disconnected. -@subsection joystick_userptr Joystick user pointer +### Joystick user pointer {#joystick_userptr} Each joystick has a user pointer that can be set with @ref glfwSetJoystickUserPointer and queried with @ref glfwGetJoystickUserPointer. @@ -691,7 +691,7 @@ terminated. The initial value of the pointer is `NULL`. -@subsection joystick_event Joystick configuration changes +### Joystick configuration changes {#joystick_event} If you wish to be notified when a joystick is connected or disconnected, set a joystick callback. @@ -728,7 +728,7 @@ useful values for a disconnected joystick and only before the monitor callback returns. -@subsection gamepad Gamepad input +### Gamepad input {#gamepad} The joystick functions provide unlabeled axes, buttons and hats, with no indication of where they are located on the device. Their order may also vary @@ -809,7 +809,7 @@ The `GLFW_GAMEPAD_BUTTON_LAST` and `GLFW_GAMEPAD_AXIS_LAST` constants equal the largest available index for each array. -@subsection gamepad_mapping Gamepad mappings +### Gamepad mappings {#gamepad_mapping} GLFW contains a copy of the mappings available in [SDL_GameControllerDB](https://github.com/gabomdq/SDL_GameControllerDB) at the @@ -892,7 +892,7 @@ were recently added to SDL. The input modifiers `+`, `-` and `~` are supported and described above. -@section time Time input +## Time input {#time} GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime. @@ -929,7 +929,7 @@ uint64_t frequency = glfwGetTimerFrequency(); @endcode -@section clipboard Clipboard input and output +## Clipboard input and output {#clipboard} If the system clipboard contains a UTF-8 encoded string or if it can be converted to one, you can retrieve it with @ref glfwGetClipboardString. See the @@ -954,7 +954,7 @@ glfwSetClipboardString(NULL, "A string with words in it"); @endcode -@section path_drop Path drop input +## Path drop input {#path_drop} If you wish to receive the paths of files and/or directories dropped on a window, set a file drop callback. diff --git a/docs/internal.md b/docs/internal.md index ff281e46..46fc8bae 100644 --- a/docs/internal.md +++ b/docs/internal.md @@ -1,4 +1,4 @@ -@page internals_guide Internal structure +# Internal structure {#internals_guide} @tableofcontents @@ -6,7 +6,7 @@ There are several interfaces inside GLFW. Each interface has its own area of responsibility and its own naming conventions. -@section internals_public Public interface +## Public interface {#internals_public} The most well-known is the public interface, described in the glfw3.h header file. This is implemented in source files shared by all platforms and these @@ -20,7 +20,7 @@ it use headless camel case. Examples: `glfwCreateWindow`, `GLFWwindow`, `GLFW_RED_BITS` -@section internals_native Native interface +## Native interface {#internals_native} The [native interface](@ref native) is a small set of publicly available but platform-specific functions, described in the glfw3native.h header file and @@ -34,7 +34,7 @@ from. Examples: `glfwGetX11Window`, `glfwGetWGLContext` -@section internals_internal Internal interface +## Internal interface {#internals_internal} The internal interface consists of utility functions used by all other interfaces. It is shared code implemented in the same shared source files as @@ -50,7 +50,7 @@ global names have a leading underscore. Examples: `_glfwIsValidContextConfig`, `_GLFWwindow`, `_glfw.monitorCount` -@section internals_platform Platform interface +## Platform interface {#internals_platform} The platform interface implements all platform-specific operations as a service to the public interface. This includes event processing. The platform @@ -88,7 +88,7 @@ prevents shared code from accidentally using these members. Examples: `window->win32.handle`, `_glfw.x11.display` -@section internals_event Event interface +## Event interface {#internals_event} The event interface is implemented in the same shared source files as the public interface and is responsible for delivering the events it receives to the @@ -100,7 +100,7 @@ ObjectEvent pattern. Examples: `_glfwInputWindowFocus`, `_glfwInputCursorPos` -@section internals_static Static functions +## Static functions {#internals_static} Static functions may be used by any interface and have no prefixes or suffixes. These use headless camel case. @@ -108,7 +108,7 @@ These use headless camel case. Examples: `isValidElementForJoystick` -@section internals_config Configuration macros +## Configuration macros {#internals_config} GLFW uses a number of configuration macros to select at compile time which interfaces and code paths to use. They are defined in the GLFW CMake target. diff --git a/docs/intro.md b/docs/intro.md index 085cdd7e..35334c7b 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -1,4 +1,4 @@ -@page intro_guide Introduction to the API +# Introduction to the API {#intro_guide} @tableofcontents @@ -16,7 +16,7 @@ There are also guides for the other areas of GLFW. - @ref input_guide -@section intro_init Initialization and termination +## Initialization and termination {#intro_init} Before most GLFW functions may be called, the library must be initialized. This initialization checks what features are available on the machine, @@ -41,7 +41,7 @@ Calling any other function before successful initialization will cause a @ref GLFW_NOT_INITIALIZED error. -@subsection intro_init_init Initializing GLFW +### Initializing GLFW {#intro_init_init} The library is initialized with @ref glfwInit, which returns `GLFW_FALSE` if an error occurred. @@ -69,7 +69,7 @@ main menu and dock icon can be disabled with the @ref GLFW_COCOA_MENUBAR init hint. -@subsection init_hints Initialization hints +### Initialization hints {#init_hints} Initialization hints are set before @ref glfwInit and affect how the library behaves until termination. Hints are set with @ref glfwInitHint. @@ -87,7 +87,7 @@ will only affect their specific platform. Other platforms will ignore them. Setting these hints requires no platform specific headers or functions. -@subsubsection init_hints_shared Shared init hints +#### Shared init hints {#init_hints_shared} @anchor GLFW_PLATFORM __GLFW_PLATFORM__ specifies the platform to use for windowing and input. @@ -118,7 +118,7 @@ extension. This extension is not used if this hint is `GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value. -@subsubsection init_hints_osx macOS specific init hints +#### macOS specific init hints {#init_hints_osx} @anchor GLFW_COCOA_CHDIR_RESOURCES_hint __GLFW_COCOA_CHDIR_RESOURCES__ specifies whether to set the current directory to @@ -133,7 +133,7 @@ a nib or manually by GLFW. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is ignored on other platforms. -@subsubsection init_hints_x11 X11 specific init hints +#### X11 specific init hints {#init_hints_x11} @anchor GLFW_X11_XCB_VULKAN_SURFACE_hint __GLFW_X11_XCB_VULKAN_SURFACE__ specifies whether to prefer the @@ -142,7 +142,7 @@ the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is ignored on other platforms. -@subsubsection init_hints_wayland Wayland specific init hints +#### Wayland specific init hints {#init_hints_wayland} @anchor GLFW_WAYLAND_LIBDECOR_hint __GLFW_WAYLAND_LIBDECOR__ specifies whether to use @@ -151,7 +151,7 @@ decorations where available. Possible values are `GLFW_WAYLAND_PREFER_LIBDECOR` and `GLFW_WAYLAND_DISABLE_LIBDECOR`. This is ignored on other platforms. -@subsubsection init_hints_values Supported and default values +#### Supported and default values {#init_hints_values} Initialization hint | Default value | Supported values -------------------------------- | ------------------------------- | ---------------- @@ -164,7 +164,7 @@ Initialization hint | Default value | Supported v @ref GLFW_WAYLAND_LIBDECOR | `GLFW_WAYLAND_PREFER_LIBDECOR` | `GLFW_WAYLAND_PREFER_LIBDECOR` or `GLFW_WAYLAND_DISABLE_LIBDECOR` -@subsection platform Runtime platform selection +### Runtime platform selection {#platform} GLFW can be compiled for more than one platform (window system) at once. This lets a single library binary support both X11 and Wayland on Linux and other Unix-like systems. @@ -206,7 +206,7 @@ Unix-like systems, then you may need to check that you are calling the ones matc selected platform. -@subsection init_allocator Custom heap memory allocator +### Custom heap memory allocator {#init_allocator} The heap memory allocator can be customized before initialization with @ref glfwInitAllocator. @@ -273,7 +273,7 @@ The documentation for @ref GLFWdeallocatefun also lists the requirements and lim for a deallocation function. If the active one does not meet all of these, GLFW may fail. -@subsection intro_init_terminate Terminating GLFW +### Terminating GLFW {#intro_init_terminate} Before your application exits, you should terminate the GLFW library if it has been initialized. This is done with @ref glfwTerminate. @@ -292,7 +292,7 @@ library was not initialized or had already been terminated, it returns immediately. -@section error_handling Error handling +## Error handling {#error_handling} Some GLFW functions have return values that indicate an error, but this is often not very helpful when trying to figure out what happened or why it occurred. @@ -367,7 +367,7 @@ Do not rely on a currently invalid call to generate a specific error, as in the future that same call may generate a different error or become valid. -@section coordinate_systems Coordinate systems +## Coordinate systems {#coordinate_systems} GLFW has two primary coordinate systems: the _virtual screen_ and the window _content area_ or _content area_. Both use the same unit: _virtual screen @@ -404,7 +404,7 @@ between screen coordinates and pixels may also change at run-time depending on which monitor the window is currently considered to be on. -@section guarantees_limitations Guarantees and limitations +## Guarantees and limitations {#guarantees_limitations} This section describes the conditions under which GLFW can be expected to function, barring bugs in the operating system or drivers. Use of GLFW outside @@ -413,7 +413,7 @@ time, or on some versions of GLFW, but it may break at any time and this will not be considered a bug. -@subsection lifetime Pointer lifetimes +### Pointer lifetimes {#lifetime} GLFW will never free any pointer you provide to it, and you must never free any pointer it provides to you. @@ -433,7 +433,7 @@ Pointer lifetimes are guaranteed not to be shortened in future minor or patch releases. -@subsection reentrancy Reentrancy +### Reentrancy {#reentrancy} GLFW event processing and object destruction are not reentrant. This means that the following functions must not be called from any callback function: @@ -449,7 +449,7 @@ These functions may be made reentrant in future minor or patch releases, but functions not on this list will not be made non-reentrant. -@subsection thread_safety Thread safety +### Thread safety {#thread_safety} Most GLFW functions must only be called from the main thread (the thread that calls main), but some may be called from any thread once the library has been @@ -530,7 +530,7 @@ but functions that are currently limited to the main thread may be updated to allow calls from any thread in future releases. -@subsection compatibility Version compatibility +### Version compatibility {#compatibility} GLFW uses [Semantic Versioning](https://semver.org/). This guarantees source and binary backward compatibility with earlier minor versions of the API. This @@ -550,14 +550,14 @@ fixed in the next release. The reference documentation will also take precedence over anything stated in a guide. -@subsection event_order Event order +### Event order {#event_order} The order of arrival of related events is not guaranteed to be consistent across platforms. The exception is synthetic key and mouse button release events, which are always delivered after the window defocus event. -@section intro_version Version management +## Version management {#intro_version} GLFW provides mechanisms for identifying what version of GLFW your application was compiled against as well as what version it is currently running against. @@ -565,7 +565,7 @@ If you are loading GLFW dynamically (not just linking dynamically), you can use this to verify that the library binary is compatible with your application. -@subsection intro_version_compile Compile-time version +### Compile-time version {#intro_version_compile} The compile-time version of GLFW is provided by the GLFW header with the `GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros. @@ -578,7 +578,7 @@ printf("Compiled against GLFW %i.%i.%i\n", @endcode -@subsection intro_version_runtime Run-time version +### Run-time version {#intro_version_runtime} The run-time version can be retrieved with @ref glfwGetVersion, a function that may be called regardless of whether GLFW is initialized. @@ -591,7 +591,7 @@ printf("Running against GLFW %i.%i.%i\n", major, minor, revision); @endcode -@subsection intro_version_string Version string +### Version string {#intro_version_string} GLFW 3 also provides a compile-time generated version string that describes the version, platform, compiler and any platform-specific compile-time options. diff --git a/docs/main.md b/docs/main.md index 53faeea9..4f86b8af 100644 --- a/docs/main.md +++ b/docs/main.md @@ -1,6 +1,4 @@ -@mainpage notitle - -@section main_intro Introduction +# Introduction {#mainpage} GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan application development. It provides a simple, platform-independent API diff --git a/docs/monitor.md b/docs/monitor.md index 5aa5ed7f..b4ba75c4 100644 --- a/docs/monitor.md +++ b/docs/monitor.md @@ -1,4 +1,4 @@ -@page monitor_guide Monitor guide +# Monitor guide {#monitor_guide} @tableofcontents @@ -13,7 +13,7 @@ guides for the other areas of GLFW. - @ref input_guide -@section monitor_object Monitor objects +## Monitor objects {#monitor_object} A monitor object represents a currently connected monitor and is represented as a pointer to the [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @@ -34,7 +34,7 @@ To see how GLFW views your monitor setup and its available video modes, run the `monitors` test program. -@subsection monitor_monitors Retrieving monitors +### Retrieving monitors {#monitor_monitors} The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is the user's preferred monitor and is usually the one with global UI elements like task bar @@ -57,7 +57,7 @@ monitors may be moved to a different index when a monitor is connected or disconnected. -@subsection monitor_event Monitor configuration changes +### Monitor configuration changes {#monitor_event} If you wish to be notified when a monitor is connected or disconnected, set a monitor callback. @@ -89,14 +89,14 @@ glfwGetMonitorName and @ref glfwGetMonitorUserPointer will return useful values for a disconnected monitor and only before the monitor callback returns. -@section monitor_properties Monitor properties +## Monitor properties {#monitor_properties} Each monitor has a current video mode, a list of supported video modes, 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 +### Video modes {#monitor_modes} GLFW generally does a good job selecting a suitable video mode when you create a full screen window, change its video mode or make a windowed one full @@ -123,7 +123,7 @@ The resolution of a video mode is specified in [screen coordinates](@ref coordinate_systems), not pixels. -@subsection monitor_size Physical size +### Physical size {#monitor_size} The physical size of a monitor in millimetres, or an estimation of it, can be retrieved with @ref glfwGetMonitorPhysicalSize. This has no relation to its @@ -140,7 +140,7 @@ useful. Instead, use the [monitor content scale](@ref monitor_scale) and [window content scale](@ref window_scale) to scale your content. -@subsection monitor_scale Content scale +### Content scale {#monitor_scale} The content scale for a monitor can be retrieved with @ref glfwGetMonitorContentScale. @@ -162,7 +162,7 @@ and on user settings. It may be very different from the raw DPI calculated from the physical size and current resolution. -@subsection monitor_pos Virtual position +### Virtual position {#monitor_pos} The position of the monitor on the virtual desktop, in [screen coordinates](@ref coordinate_systems), can be retrieved with @ref @@ -174,7 +174,7 @@ glfwGetMonitorPos(monitor, &xpos, &ypos); @endcode -@subsection monitor_workarea Work area +### Work area {#monitor_workarea} The area of a monitor not occupied by global task bars or menu bars is the work area. This is specified in [screen coordinates](@ref coordinate_systems) and @@ -186,7 +186,7 @@ glfwGetMonitorWorkarea(monitor, &xpos, &ypos, &width, &height); @endcode -@subsection monitor_name Human-readable name +### Human-readable name {#monitor_name} The human-readable, UTF-8 encoded name of a monitor is returned by @ref glfwGetMonitorName. See the reference documentation for the lifetime of the @@ -201,7 +201,7 @@ and make may have the same name. Only the monitor handle is guaranteed to be unique, and only until that monitor is disconnected. -@subsection monitor_userptr User pointer +### User pointer {#monitor_userptr} Each monitor has a user pointer that can be set with @ref glfwSetMonitorUserPointer and queried with @ref glfwGetMonitorUserPointer. This @@ -212,7 +212,7 @@ terminated. The initial value of the pointer is `NULL`. -@subsection monitor_gamma Gamma ramp +### Gamma ramp {#monitor_gamma} The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts a monitor handle and a pointer to a @ref GLFWgammaramp structure. diff --git a/docs/moving.md b/docs/moving.md index fe4f30b8..86068dbe 100644 --- a/docs/moving.md +++ b/docs/moving.md @@ -1,4 +1,4 @@ -@page moving_guide Moving from GLFW 2 to 3 +# Moving from GLFW 2 to 3 {#moving_guide} @tableofcontents @@ -9,9 +9,9 @@ base onto the new API. For example, the new multi-monitor functions are required to create full screen windows with GLFW 3. -@section moving_removed Changed and removed features +## Changed and removed features {#moving_removed} -@subsection moving_renamed_files Renamed library and header file +### Renamed library and header file {#moving_renamed_files} The GLFW 3 header is named @ref glfw3.h and moved to the `GLFW` directory, to avoid collisions with the headers of other major versions. Similarly, the GLFW @@ -30,7 +30,7 @@ Unix-like systems, where it uses the @endcode -@subsection moving_threads Removal of threading functions +### Removal of threading functions {#moving_threads} The threading functions have been removed, including the per-thread sleep function. They were fairly primitive, under-used, poorly integrated and took @@ -63,7 +63,7 @@ used from any thread and which must only be used from the main thread. `GLFWthreadfun` -@subsection moving_image Removal of image and texture loading +### Removal of image and texture loading {#moving_image} The image and texture loading functions have been removed. They only supported the Targa image format, making them mostly useful for beginner level examples. @@ -82,7 +82,7 @@ platform-independent, as both OpenGL and stdio are available wherever GLFW is. `glfwLoadMemoryTexture2D` and `glfwLoadTextureImage2D`. -@subsection moving_stdcall Removal of GLFWCALL macro +### Removal of GLFWCALL macro {#moving_stdcall} The `GLFWCALL` macro, which made callback functions use [__stdcall](https://msdn.microsoft.com/en-us/library/zxk0tw93.aspx) on Windows, @@ -103,7 +103,7 @@ void callback_function(...); @endcode -@subsection moving_window_handles Window handle parameters +### Window handle parameters {#moving_window_handles} Because GLFW 3 supports multiple windows, window handle parameters have been added to all window-related GLFW functions and callbacks. The handle of @@ -122,7 +122,7 @@ glfwSetWindowTitle(window, "New Window Title"); @endcode -@subsection moving_monitor Explicit monitor selection +### Explicit monitor selection {#moving_monitor} GLFW 3 provides support for multiple monitors. To request a full screen mode window, instead of passing `GLFW_FULLSCREEN` you specify which monitor you wish the @@ -146,7 +146,7 @@ into [window hints](@ref window_hints), but as they have been given [sane defaults](@ref window_hints_values) you rarely need to set these hints. -@subsection moving_autopoll Removal of automatic event polling +### Removal of automatic event polling {#moving_autopoll} GLFW 3 does not automatically poll for events in @ref glfwSwapBuffers, meaning you need to call @ref glfwPollEvents or @ref glfwWaitEvents yourself. Unlike @@ -175,7 +175,7 @@ while (...) @endcode -@subsection moving_context Explicit context management +### Explicit context management {#moving_context} Each GLFW 3 window has its own OpenGL context and only you, the application programmer, can know which context should be current on which thread at any @@ -185,7 +185,7 @@ This means that you need to call @ref glfwMakeContextCurrent after creating a window before you can call any OpenGL functions. -@subsection moving_hidpi Separation of window and framebuffer sizes +### Separation of window and framebuffer sizes {#moving_hidpi} Window positions and sizes now use screen coordinates, which may not be the same as pixels on machines with high-DPI monitors. This is important as OpenGL uses @@ -208,7 +208,7 @@ glViewport(0, 0, width, height); @endcode -@subsection moving_window_close Window closing changes +### Window closing changes {#moving_window_close} The `GLFW_OPENED` window parameter has been removed. As long as the window has not been destroyed, whether through @ref glfwDestroyWindow or @ref @@ -260,7 +260,7 @@ for other reasons to close the window as well, for example the user choosing Quit from an in-game menu. -@subsection moving_hints Persistent window hints +### Persistent window hints {#moving_hints} The `glfwOpenWindowHint` function has been renamed to @ref glfwWindowHint. @@ -269,7 +269,7 @@ instead retain their values until modified by @ref glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is terminated and re-initialized. -@subsection moving_video_modes Video mode enumeration +### Video mode enumeration {#moving_video_modes} Video mode enumeration is now per-monitor. The @ref glfwGetVideoModes function now returns all available modes for a specific monitor instead of requiring you @@ -278,7 +278,7 @@ had poorly defined behavior, has been replaced by @ref glfwGetVideoMode, which returns the current mode of a monitor. -@subsection moving_char_up Removal of character actions +### Removal of character actions {#moving_char_up} The action parameter of the [character callback](@ref GLFWcharfun) has been removed. This was an artefact of the origin of GLFW, i.e. being developed in @@ -297,7 +297,7 @@ void character_callback(GLFWwindow* window, int character); @endcode -@subsection moving_cursorpos Cursor position changes +### Cursor position changes {#moving_cursorpos} The `glfwGetMousePos` function has been renamed to @ref glfwGetCursorPos, `glfwSetMousePos` to @ref glfwSetCursorPos and `glfwSetMousePosCallback` to @ref @@ -313,7 +313,7 @@ glfwSetCursorPos (formerly `glfwSetMousePos`) when that window is active. Unless the window is active, the function fails silently. -@subsection moving_wheel Wheel position replaced by scroll offsets +### Wheel position replaced by scroll offsets {#moving_wheel} The `glfwGetMouseWheel` function has been removed. Scrolling is the input of offsets and has no absolute position. The mouse wheel callback has been @@ -335,7 +335,7 @@ void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); `glfwGetMouseWheel` -@subsection moving_repeat Key repeat action +### Key repeat action {#moving_repeat} The `GLFW_KEY_REPEAT` enable has been removed and key repeat is always enabled for both keys and characters. A new key action, `GLFW_REPEAT`, has been added @@ -344,7 +344,7 @@ from a repeat. Note that @ref glfwGetKey still returns only `GLFW_PRESS` or `GLFW_RELEASE`. -@subsection moving_keys Physical key input +### Physical key input {#moving_keys} GLFW 3 key tokens map to physical keys, unlike in GLFW 2 where they mapped to the values generated by the current keyboard layout. The tokens are named @@ -364,7 +364,7 @@ having to remember whether to check for `a` or `A`, you now check for @ref GLFW_KEY_A. -@subsection moving_joystick Joystick function changes +### Joystick function changes {#moving_joystick} The `glfwGetJoystickPos` function has been renamed to @ref glfwGetJoystickAxes. @@ -374,7 +374,7 @@ function as well as axis and button counts returned by the @ref glfwGetJoystickAxes and @ref glfwGetJoystickButtons functions. -@subsection moving_mbcs Win32 MBCS support +### Win32 MBCS support {#moving_mbcs} The Win32 port of GLFW 3 will not compile in [MBCS mode](https://msdn.microsoft.com/en-us/library/5z097dxa.aspx). @@ -385,7 +385,7 @@ Therefore, even if an application using GLFW has MBCS mode code, there's no need for GLFW itself to support it. -@subsection moving_windows Support for versions of Windows older than XP +### Support for versions of Windows older than XP {#moving_windows} All explicit support for version of Windows older than XP has been removed. There is no code that actively prevents GLFW 3 from running on these earlier @@ -405,7 +405,7 @@ runtime checking for a number of functions that are present only on modern version of Windows. -@subsection moving_syskeys Capture of system-wide hotkeys +### Capture of system-wide hotkeys {#moving_syskeys} The ability to disable and capture system-wide hotkeys like Alt+Tab has been removed. Modern applications, whether they're games, scientific visualisations @@ -413,7 +413,7 @@ or something else, are nowadays expected to be good desktop citizens and allow these hotkeys to function even when running in full screen mode. -@subsection moving_terminate Automatic termination +### Automatic termination {#moving_terminate} GLFW 3 does not register @ref glfwTerminate with `atexit` at initialization, because `exit` calls registered functions from the calling thread and while it @@ -426,7 +426,7 @@ destroys all windows not already destroyed with @ref glfwDestroyWindow, invalidating any window handles you may still have. -@subsection moving_glu GLU header inclusion +### GLU header inclusion {#moving_glu} GLFW 3 does not by default include the GLU header and GLU itself has been deprecated by [Khronos](https://en.wikipedia.org/wiki/Khronos_Group). __New @@ -453,10 +453,10 @@ tessellation functions, see for example [libtess2](https://github.com/memononen/libtess2). -@section moving_tables Name change tables +## Name change tables {#moving_tables} -@subsection moving_renamed_functions Renamed functions +### Renamed functions {#moving_renamed_functions} | GLFW 2 | GLFW 3 | Notes | | --------------------------- | ----------------------------- | ----- | @@ -476,7 +476,7 @@ tessellation functions, see for example | `glfwGetJoystickParam` | @ref glfwJoystickPresent | The axis and button counts are provided by @ref glfwGetJoystickAxes and @ref glfwGetJoystickButtons | -@subsection moving_renamed_types Renamed types +### Renamed types {#moving_renamed_types} | GLFW 2 | GLFW 3 | Notes | | ------------------- | --------------------- | | @@ -484,7 +484,7 @@ tessellation functions, see for example | `GLFWmouseposfun` | @ref GLFWcursorposfun | | -@subsection moving_renamed_tokens Renamed tokens +### Renamed tokens {#moving_renamed_tokens} | GLFW 2 | GLFW 3 | Notes | | --------------------------- | ---------------------------- | ----- | diff --git a/docs/news.md b/docs/news.md index b316b8db..75928860 100644 --- a/docs/news.md +++ b/docs/news.md @@ -1,13 +1,13 @@ -@page news Release notes +# Release notes {#news} @tableofcontents -@section news_34 Release notes for version 3.4 +## Release notes for version 3.4 {#news_34} -@subsection features_34 New features in version 3.4 +### New features in version 3.4 {#features_34} -@subsubsection runtime_platform_34 Runtime platform selection +#### Runtime platform selection {#runtime_platform_34} GLFW now supports being compiled for multiple backends and selecting between them at runtime with the @ref GLFW_PLATFORM init hint. After initialization the @@ -15,7 +15,7 @@ selected platform can be queried with @ref glfwGetPlatform. You can check if support for a given platform is compiled in with @ref glfwPlatformSupported. -@subsubsection standard_cursors_34 More standard cursors +#### More standard cursors {#standard_cursors_34} 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 @@ -33,7 +33,7 @@ are still available. For more information see @ref cursor_standard. -@subsubsection mouse_passthrough_34 Mouse event passthrough +#### Mouse event passthrough {#mouse_passthrough_34} GLFW now provides the [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint) window hint for making a window transparent to mouse input, lettings events pass @@ -41,7 +41,7 @@ to whatever window is behind it. This can also be changed after window creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib). -@subsubsection wayland_libdecor_34 Wayland libdecor decorations +#### Wayland libdecor decorations {#wayland_libdecor_34} GLFW now supports improved fallback window decorations via [libdecor](https://gitlab.freedesktop.org/libdecor/libdecor). @@ -51,13 +51,13 @@ Support for libdecor can be toggled before GLFW is initialized with the enabled by default. -@subsubsection wayland_app_id_34 Wayland app_id specification +#### Wayland app_id specification {#wayland_app_id_34} GLFW now supports specifying the app_id for a Wayland window using the [GLFW_WAYLAND_APP_ID](@ref GLFW_WAYLAND_APP_ID_hint) window hint string. -@subsubsection features_34_angle_backend Support for ANGLE rendering backend selection +#### Support for ANGLE rendering backend selection {#features_34_angle_backend} GLFW now provides the [GLFW_ANGLE_PLATFORM_TYPE](@ref GLFW_ANGLE_PLATFORM_TYPE_hint) init hint for @@ -66,7 +66,7 @@ requesting a specific rendering backend when using contexts. -@subsubsection captured_cursor_34 Captured cursor mode +#### Captured cursor mode {#captured_cursor_34} GLFW now supports confining the cursor to the window content area with the @ref GLFW_CURSOR_CAPTURED cursor mode. @@ -74,7 +74,7 @@ GLFW_CURSOR_CAPTURED cursor mode. For more information see @ref cursor_mode. -@subsubsection features_34_init_allocator Support for custom memory allocator +#### Support for custom memory allocator {#features_34_init_allocator} GLFW now supports plugging a custom memory allocator at initialization with @ref glfwInitAllocator. The allocator is a struct of type @ref GLFWallocator with @@ -84,7 +84,7 @@ function pointers corresponding to the standard library functions `malloc`, For more information see @ref init_allocator. -@subsubsection features_34_position_hint Window hints for initial position +#### Window hints for initial position {#features_34_position_hint} GLFW now provides the @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints for specifying the initial position of the window. This removes the need to create a hidden @@ -92,7 +92,7 @@ window, move it and then show it. The default value of these hints is `GLFW_ANY_POSITION`, which selects the previous behavior. -@subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu +#### Support for keyboard access to Windows window menu {#features_34_win32_keymenu} GLFW now provides the [GLFW_WIN32_KEYBOARD_MENU](@ref GLFW_WIN32_KEYBOARD_MENU_hint) window hint for @@ -101,16 +101,16 @@ Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented applications. -@subsubsection features_34_win32_showdefault Support for applying STARTUPINFO show command +#### Support for applying STARTUPINFO show command {#features_34_win32_showdefault} GLFW now provides the [GLFW_WIN32_SHOWDEFAULT](@ref GLFW_WIN32_SHOWDEFAULT_hint) window hint for applying the show command in the program's `STARTUPINFO` when showing the window for the first time. This may be useful for the main window of a windowed-mode tool. -@subsection caveats Caveats for version 3.4 +### Caveats for version 3.4 {#caveats} -@subsubsection native_34 Multiple sets of native access functions +#### Multiple sets of native access functions {#native_34} Because GLFW now supports runtime selection of platform (window system), a library binary may export native access functions for multiple platforms. Starting with version 3.4 you @@ -119,14 +119,14 @@ functions for it. After initialization, you can query the selected platform wit glfwGetPlatform. -@subsubsection version_string_34 Version string format has been changed +#### Version string format has been changed {#version_string_34} Because GLFW now supports runtime selection of platform (window system), the version string returned by @ref glfwGetVersionString has been expanded. It now contains the names of all APIs for all the platforms that the library binary supports. -@subsubsection joysticks_34 Joystick support is initialized on demand +#### Joystick support is initialized on demand {#joysticks_34} The joystick part of GLFW is now initialized when first used, primarily to work around faulty Windows drivers that cause DirectInput to take up to several @@ -141,7 +141,7 @@ To work around this, call any joystick function before waiting for events, for example by setting a [joystick callback](@ref joystick_event). -@subsubsection wayland_alpha_34 Framebuffer may lack alpha channel on older Wayland systems +#### Framebuffer may lack alpha channel on older Wayland systems {#wayland_alpha_34} On Wayland, when creating an EGL context on a machine lacking the new `EGL_EXT_present_opaque` extension, the @ref GLFW_ALPHA_BITS window hint will be @@ -154,7 +154,7 @@ If you want a per-pixel transparent window, see the hint. -@subsubsection standalone_34 Tests and examples are disabled when built as a subproject +#### Tests and examples are disabled when built as a subproject {#standalone_34} 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 @@ -168,37 +168,37 @@ add_subdirectory(path/to/glfw) @endcode -@subsubsection initmenu_34 macOS main menu now created at initialization +#### macOS main menu now created at initialization {#initmenu_34} 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 +#### CoreVideo dependency has been removed {#corevideo_34} GLFW no longer depends on the CoreVideo framework on macOS and it no longer needs to be specified during compilation or linking. -@subsubsection caveat_fbtransparency_34 Framebuffer transparency requires DWM transparency +#### Framebuffer transparency requires DWM transparency {#caveat_fbtransparency_34} GLFW no longer supports framebuffer transparency enabled via @ref GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off (the Transparency setting under Personalization > Window Color). -@subsubsection emptyevents_34 Empty events on X11 no longer round-trip to server +#### Empty events on X11 no longer round-trip to server {#emptyevents_34} Events posted with @ref glfwPostEmptyEvent now use a separate unnamed pipe instead of sending an X11 client event to the helper window. -@subsection deprecations_34 Deprecations in version 3.4 +### Deprecations in version 3.4 {#deprecations_34} -@subsection removals_34 Removals in 3.4 +### Removals in 3.4 {#removals_34} -@subsubsection vulkan_static_34 GLFW_VULKAN_STATIC CMake option has been removed +#### GLFW_VULKAN_STATIC CMake option has been removed {#vulkan_static_34} This option was used to compile GLFW directly linked with the Vulkan loader, instead of using dynamic loading to get hold of `vkGetInstanceProcAddr` at initialization. This is @@ -209,7 +209,7 @@ have no effect. The call to @ref glfwInitVulkanLoader can be conditionally enab your code by checking the @ref GLFW_VERSION_MAJOR and @ref GLFW_VERSION_MINOR macros. -@subsubsection osmesa_option_34 GLFW_USE_OSMESA CMake option has been removed +#### GLFW_USE_OSMESA CMake option has been removed {#osmesa_option_34} This option was used to compile GLFW for the Null platform. The Null platform is now always supported. To produce a library binary that only supports this platform, the way @@ -221,16 +221,16 @@ You can set all of them to false and the ones that don't apply for the target OS ignored. -@subsubsection wl_shell_34 Support for the wl_shell protocol has been removed +#### Support for the wl_shell protocol has been removed {#wl_shell_34} 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 +### New symbols in version 3.4 {#symbols_34} -@subsubsection functions_34 New functions in version 3.4 +#### New functions in version 3.4 {#functions_34} - @ref glfwInitAllocator - @ref glfwGetPlatform @@ -238,7 +238,7 @@ then GLFW will fail to initialize. - @ref glfwInitVulkanLoader -@subsubsection types_34 New types in version 3.4 +#### New types in version 3.4 {#types_34} - @ref GLFWallocator - @ref GLFWallocatefun @@ -246,7 +246,7 @@ then GLFW will fail to initialize. - @ref GLFWdeallocatefun -@subsubsection constants_34 New constants in version 3.4 +#### New constants in version 3.4 {#constants_34} - @ref GLFW_PLATFORM - @ref GLFW_ANY_PLATFORM @@ -289,7 +289,7 @@ then GLFW will fail to initialize. - @ref GLFW_WAYLAND_DISABLE_LIBDECOR -@section news_archive Release notes for earlier versions +## Release notes for earlier versions {#news_archive} - [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) diff --git a/docs/quick.md b/docs/quick.md index 03688d53..1ac22e51 100644 --- a/docs/quick.md +++ b/docs/quick.md @@ -1,4 +1,4 @@ -@page quick_guide Getting started +# Getting started {#quick_guide} @tableofcontents @@ -12,9 +12,9 @@ have used GLFW 2 in the past, read @ref moving_guide, as some functions behave differently in GLFW 3. -@section quick_steps Step by step +## Step by step {#quick_steps} -@subsection quick_include Including the GLFW header +### Including the GLFW header {#quick_include} In the source files of your application where you use GLFW, you need to include its header file. @@ -53,7 +53,7 @@ in any order. @endcode -@subsection quick_init_term Initializing and terminating GLFW +### Initializing and terminating GLFW {#quick_init_term} Before you can use most GLFW functions, the library must be initialized. On successful initialization, `GLFW_TRUE` is returned. If an error occurred, @@ -80,7 +80,7 @@ GLFW. After this call, you must initialize GLFW again before using any GLFW functions that require it. -@subsection quick_capture_error Setting an error callback +### Setting an error callback {#quick_capture_error} Most events are reported through callbacks, whether it's a key being pressed, a GLFW window being moved, or an error occurring. Callbacks are C functions (or @@ -107,7 +107,7 @@ glfwSetErrorCallback(error_callback); @endcode -@subsection quick_create_window Creating a window and context +### Creating a window and context {#quick_create_window} The window and its OpenGL context are created with a single call to @ref glfwCreateWindow, which returns a handle to the created combined window and @@ -157,7 +157,7 @@ Once this function is called, no more events will be delivered for that window and its handle becomes invalid. -@subsection quick_context_current Making the OpenGL context current +### Making the OpenGL context current {#quick_context_current} Before you can use the OpenGL API, you must have a current OpenGL context. @@ -179,7 +179,7 @@ gladLoadGL(glfwGetProcAddress); @endcode -@subsection quick_window_close Checking the window close flag +### Checking the window close flag {#quick_window_close} Each window has a flag indicating whether the window should be closed. @@ -205,7 +205,7 @@ useful if you want to interpret other kinds of input as closing the window, like for example pressing the _Escape_ key. -@subsection quick_key_input Receiving input events +### Receiving input events {#quick_key_input} Each window has a large number of callbacks that can be set to receive all the various kinds of events. To receive key press and release events, create a key @@ -229,7 +229,7 @@ In order for event callbacks to be called when events occur, you need to process events as described below. -@subsection quick_render Rendering with OpenGL +### Rendering with OpenGL {#quick_render} Once you have a current OpenGL context, you can use OpenGL normally. In this tutorial, a multicolored rotating triangle will be rendered. The framebuffer @@ -256,7 +256,7 @@ 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 +### Reading the timer {#quick_timer} To create smooth animation, a time source is needed. GLFW provides a timer that returns the number of seconds since initialization. The time source used is the @@ -268,7 +268,7 @@ double time = glfwGetTime(); @endcode -@subsection quick_swap_buffers Swapping buffers +### Swapping buffers {#quick_swap_buffers} GLFW windows by default use double buffering. That means that each window has two rendering buffers; a front buffer and a back buffer. The front buffer is @@ -302,7 +302,7 @@ This function acts on the current context and will fail unless a context is current. -@subsection quick_process_events Processing events +### Processing events {#quick_process_events} GLFW needs to communicate regularly with the window system both in order to receive events and to show that the application hasn't locked up. Event @@ -325,7 +325,7 @@ all received events. This saves a great deal of CPU cycles and is useful for, for example, many kinds of editing tools. -@section quick_example Putting it together +## Putting it together {#quick_example} Now that you know how to initialize GLFW, create a window and poll for keyboard input, it's possible to create a small program. diff --git a/docs/vulkan.md b/docs/vulkan.md index 9208c006..b96e4c61 100644 --- a/docs/vulkan.md +++ b/docs/vulkan.md @@ -1,4 +1,4 @@ -@page vulkan_guide Vulkan guide +# Vulkan guide {#vulkan_guide} @tableofcontents @@ -27,7 +27,7 @@ are also guides for the other areas of the GLFW API. - @ref input_guide -@section vulkan_loader Finding the Vulkan loader +## Finding the Vulkan loader {#vulkan_loader} GLFW itself does not ever need to be linked against the Vulkan loader. @@ -52,7 +52,7 @@ bundle according to the LunarG SDK documentation. This is explained in more det [SDK documentation for macOS](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html). -@section vulkan_include Including the Vulkan header file +## Including the Vulkan header file {#vulkan_include} To have GLFW include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including the GLFW header. @@ -82,7 +82,7 @@ The `VK_USE_PLATFORM_*_KHR` macros do not need to be defined for the Vulkan part of GLFW to work. Define them only if you are using these extensions directly. -@section vulkan_support Querying for Vulkan support +## Querying for Vulkan support {#vulkan_support} If you are linking directly against the Vulkan loader then you can skip this section. The canonical desktop loader library exports all Vulkan core and @@ -106,7 +106,7 @@ If one or both were not found, calling any other Vulkan related GLFW function will generate a @ref GLFW_API_UNAVAILABLE error. -@subsection vulkan_proc Querying Vulkan function pointers +### Querying Vulkan function pointers {#vulkan_proc} To load any Vulkan core or extension function from the found loader, call @ref glfwGetInstanceProcAddress. To load functions needed for instance creation, @@ -145,7 +145,7 @@ dispatch internally based on the device passed to them. For more information about `vkGetDeviceProcAddr`, see the Vulkan documentation. -@section vulkan_ext Querying required Vulkan extensions +## Querying required Vulkan extensions {#vulkan_ext} To do anything useful with Vulkan you need to create an instance. If you want to use Vulkan to render to a window, you must enable the instance extensions @@ -194,7 +194,7 @@ info flags for MoltenVK to show up in the list of physical devices. For more information, see the Vulkan and MoltenVK documentation. -@section vulkan_present Querying for Vulkan presentation support +## Querying for Vulkan presentation support {#vulkan_present} Not every queue family of every Vulkan device can present images to surfaces. To check whether a specific queue family of a physical device supports image @@ -213,7 +213,7 @@ The `VK_KHR_surface` extension additionally provides the an existing Vulkan surface. -@section vulkan_window Creating the window +## Creating the window {#vulkan_window} Unless you will be using OpenGL or OpenGL ES with the same window as Vulkan, there is no need to create a context. You can disable context creation with the @@ -227,7 +227,7 @@ GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL); See @ref context_less for more information. -@section vulkan_surface Creating a Vulkan window surface +## Creating a Vulkan window surface {#vulkan_surface} You can create a Vulkan surface (as defined by the `VK_KHR_surface` extension) for a GLFW window with @ref glfwCreateWindowSurface. diff --git a/docs/window.md b/docs/window.md index 89883711..e3c8f7a9 100644 --- a/docs/window.md +++ b/docs/window.md @@ -1,4 +1,4 @@ -@page window_guide Window guide +# Window guide {#window_guide} @tableofcontents @@ -13,7 +13,7 @@ guides for the other areas of GLFW. - @ref input_guide -@section window_object Window objects +## Window objects {#window_object} The @ref GLFWwindow object encapsulates both a window and a context. They are created with @ref glfwCreateWindow and destroyed with @ref glfwDestroyWindow, or @@ -24,7 +24,7 @@ To see the event stream provided to the various window related callbacks, run the `events` test program. -@subsection window_creation Window creation +### Window creation {#window_creation} A window and its OpenGL or OpenGL ES context are created with @ref glfwCreateWindow, which returns a handle to the created window object. For @@ -42,7 +42,7 @@ along with all input events, so event handlers can tell which window received the event. -@subsubsection window_full_screen Full screen windows +#### Full screen windows {#window_full_screen} To create a full screen window, you need to specify which monitor the window should use. In most cases, the user's primary monitor is a good choice. @@ -91,7 +91,7 @@ If a monitor is disconnected, all windows that are full screen on that monitor will be switched to windowed mode. See @ref monitor_event for more information. -@subsubsection window_windowed_full_screen "Windowed full screen" windows +#### "Windowed full screen" windows {#window_windowed_full_screen} If the closest match for the desired video mode is the current one, the video mode will not be changed, making window creation faster and application @@ -123,7 +123,7 @@ so if you already have a full screen window on that monitor that you want to make windowed full screen, you need to have saved the desktop resolution before. -@subsection window_destruction Window destruction +### Window destruction {#window_destruction} When a window is no longer needed, destroy it with @ref glfwDestroyWindow. @@ -139,7 +139,7 @@ When a full screen window is destroyed, the original video mode of its monitor is restored, but the gamma ramp is left untouched. -@subsection window_hints Window creation hints +### Window creation hints {#window_hints} There are a number of hints that can be set before the creation of a window and context. Some affect the window itself, others affect the framebuffer or @@ -158,7 +158,7 @@ you wish to have the specified attributes. They function as additional arguments to @ref glfwCreateWindow. -@subsubsection window_hints_hard Hard and soft constraints +#### Hard and soft constraints {#window_hints_hard} Some window hints are hard constraints. These must match the available capabilities _exactly_ for window and context creation to succeed. Hints @@ -177,7 +177,7 @@ context, but are ignored when requesting an OpenGL ES context: - [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) -@subsubsection window_hints_wnd Window related hints +#### Window related hints {#window_hints_wnd} @anchor GLFW_RESIZABLE_hint __GLFW_RESIZABLE__ specifies whether the windowed mode window will be resizable @@ -263,7 +263,7 @@ manager will position the window where it thinks the user will prefer it. Possible values are any valid screen coordinates and `GLFW_ANY_POSITION`. -@subsubsection window_hints_fb Framebuffer related hints +#### Framebuffer related hints {#window_hints_fb} @anchor GLFW_RED_BITS @anchor GLFW_GREEN_BITS @@ -322,7 +322,7 @@ buffered. You nearly always want to use double buffering. This is a hard constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. -@subsubsection window_hints_mtr Monitor related hints +#### Monitor related hints {#window_hints_mtr} @anchor GLFW_REFRESH_RATE __GLFW_REFRESH_RATE__ specifies the desired refresh rate for full screen @@ -330,7 +330,7 @@ windows. A value of `GLFW_DONT_CARE` means the highest available refresh rate will be used. This hint is ignored for windowed mode windows. -@subsubsection window_hints_ctx Context related hints +#### Context related hints {#window_hints_ctx} @anchor GLFW_CLIENT_API_hint __GLFW_CLIENT_API__ specifies which client API to create the context for. @@ -453,7 +453,7 @@ The no error mode for OpenGL and OpenGL ES is described in detail by the extension. -@subsubsection window_hints_win32 Win32 specific hints +#### Win32 specific hints {#window_hints_win32} @anchor GLFW_WIN32_KEYBOARD_MENU_hint __GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window @@ -469,7 +469,7 @@ GLFW behaves as if this hint was set to `GLFW_FALSE`. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is ignored on other platforms. -@subsubsection window_hints_osx macOS specific hints +#### macOS specific hints {#window_hints_osx} @anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint __GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution @@ -498,7 +498,7 @@ should also declare this in its `Info.plist` by setting the `NSSupportsAutomaticGraphicsSwitching` key to `true`. -@subsubsection window_hints_x11 X11 specific window hints +#### X11 specific window hints {#window_hints_x11} @anchor GLFW_X11_CLASS_NAME_hint @anchor GLFW_X11_INSTANCE_NAME_hint @@ -507,7 +507,7 @@ ASCII encoded class and instance parts of the ICCCM `WM_CLASS` window property. hints need to be set to something other than an empty string for them to take effect. These are set with @ref glfwWindowHintString. -@subsubsection window_hints_wayland Wayland specific window hints +#### Wayland specific window hints {#window_hints_wayland} @anchor GLFW_WAYLAND_APP_ID_hint __GLFW_WAYLAND_APP_ID__ specifies the Wayland app_id for a window, used @@ -515,7 +515,7 @@ by window managers to identify types of windows. This is set with @ref glfwWindowHintString. -@subsubsection window_hints_values Supported and default values +#### Supported and default values {#window_hints_values} Window hint | Default value | Supported values ----------------------------- | --------------------------- | ---------------- @@ -568,14 +568,14 @@ GLFW_X11_INSTANCE_NAME | `""` | An ASCII encoded ` GLFW_WAYLAND_APP_ID | `""` | An ASCII encoded Wayland `app_id` name -@section window_events Window event processing +## Window event processing {#window_events} See @ref events. -@section window_properties Window properties and events +## Window properties and events {#window_properties} -@subsection window_userptr User pointer +### User pointer {#window_userptr} Each window has a user pointer that can be set with @ref glfwSetWindowUserPointer and queried with @ref glfwGetWindowUserPointer. This @@ -585,7 +585,7 @@ the life-time of the window. The initial value of the pointer is `NULL`. -@subsection window_close Window closing and close flag +### Window closing and close flag {#window_close} When the user attempts to close the window, for example by clicking the close widget or using a key chord like Alt+F4, the _close flag_ of the window is set. @@ -626,7 +626,7 @@ void window_close_callback(GLFWwindow* window) @endcode -@subsection window_size Window size +### Window size {#window_size} The size of a window can be changed with @ref glfwSetWindowSize. For windowed mode windows, this sets the size, in @@ -685,7 +685,7 @@ the content area to the corresponding edges of the full window. As they are distances and not coordinates, they are always zero or positive. -@subsection window_fbsize Framebuffer size +### Framebuffer size {#window_fbsize} While the size of a window is measured in screen coordinates, OpenGL works with pixels. The size you pass into `glViewport`, for example, should be in pixels. @@ -723,7 +723,7 @@ The size of a framebuffer may change independently of the size of a window, for example if the window is dragged between a regular monitor and a high-DPI one. -@subsection window_scale Window content scale +### Window content scale {#window_scale} The content scale for a window can be retrieved with @ref glfwGetWindowContentScale. @@ -768,7 +768,7 @@ window is created and when its content scale later changes, set the @ref GLFW_SCALE_TO_MONITOR window hint. -@subsection window_sizelimits Window size limits +### Window size limits {#window_sizelimits} The minimum and maximum size of the content area of a windowed mode window can be enforced with @ref glfwSetWindowSizeLimits. The user may resize the window @@ -814,7 +814,7 @@ You can have both size limits and aspect ratio set for a window, but the results are undefined if they conflict. -@subsection window_pos Window position +### Window position {#window_pos} By default, the window manager chooses the position of new windowed mode windows, based on its size and which monitor the user appears to be working on. @@ -863,7 +863,7 @@ glfwGetWindowPos(window, &xpos, &ypos); @endcode -@subsection window_title Window title +### Window title {#window_title} All GLFW windows have a title, although undecorated or full screen windows may not display it or only display it in a task bar or similar interface. You can @@ -890,7 +890,7 @@ glfwSetWindowTitle(window, u8"This is always a UTF-8 string"); @endcode -@subsection window_icon Window icon +### Window icon {#window_icon} Decorated windows have icons on some platforms. You can set this icon by specifying a list of candidate images with @ref glfwSetWindowIcon. @@ -914,7 +914,7 @@ glfwSetWindowIcon(window, 0, NULL); @endcode -@subsection window_monitor Window monitor +### Window monitor {#window_monitor} Full screen windows are associated with a specific monitor. You can get the handle for this monitor with @ref glfwGetWindowMonitor. @@ -952,7 +952,7 @@ that was originally windowed to its original size and position, save these before making it full screen and then pass them in as above. -@subsection window_iconify Window iconification +### Window iconification {#window_iconify} Windows can be iconified (i.e. minimized) with @ref glfwIconifyWindow. @@ -1003,7 +1003,7 @@ int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); @endcode -@subsection window_maximize Window maximization +### Window maximization {#window_maximize} Windows can be maximized (i.e. zoomed) with @ref glfwMaximizeWindow. @@ -1059,7 +1059,7 @@ glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); @endcode -@subsection window_hide Window visibility +### Window visibility {#window_hide} Windowed mode windows can be hidden with @ref glfwHideWindow. @@ -1101,7 +1101,7 @@ can be useful if you need to set up your window further before showing it, for example moving it to a specific location. -@subsection window_focus Window input focus +### Window input focus {#window_focus} Windows can be given input focus and brought to the front with @ref glfwFocusWindow. @@ -1152,7 +1152,7 @@ glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE); @endcode -@subsection window_attention Window attention request +### Window attention request {#window_attention} If you wish to notify the user of an event without interrupting, you can request attention with @ref glfwRequestWindowAttention. @@ -1166,7 +1166,7 @@ not supported, the application as a whole. Once the user has given it attention, the system will automatically end the request. -@subsection window_refresh Window damage and refresh +### Window damage and refresh {#window_refresh} If you wish to be notified when the contents of a window is damaged and needs to be refreshed, set a window refresh callback. @@ -1191,7 +1191,7 @@ window contents are saved off-screen, this callback might only be called when the window or framebuffer is resized. -@subsection window_transparency Window transparency +### Window transparency {#window_transparency} GLFW supports two kinds of transparency for windows; framebuffer transparency and whole window transparency. A single window may not use both methods. The @@ -1255,7 +1255,7 @@ overlay like for example a notification, the @ref GLFW_FLOATING and @ref GLFW_MOUSE_PASSTHROUGH window hints and attributes may be useful. -@subsection window_attribs Window attributes +### Window attributes {#window_attribs} Windows have a number of attributes that can be returned using @ref glfwGetWindowAttrib. Some reflect state that may change as a result of user @@ -1283,7 +1283,7 @@ glfwSetWindowAttrib(window, GLFW_RESIZABLE, GLFW_FALSE); -@subsubsection window_attribs_wnd Window related attributes +#### Window related attributes {#window_attribs_wnd} @anchor GLFW_FOCUSED_attrib __GLFW_FOCUSED__ indicates whether the specified window has input focus. See @@ -1351,7 +1351,7 @@ with @ref glfwSetWindowAttrib. This is only supported for undecorated windows. Decorated windows with this enabled will behave differently between platforms. -@subsubsection window_attribs_ctx Context related attributes +#### Context related attributes {#window_attribs_ctx} @anchor GLFW_CLIENT_API_attrib __GLFW_CLIENT_API__ indicates the client API provided by the window's context; @@ -1415,7 +1415,7 @@ context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION` if the window's context supports robustness, or `GLFW_NO_ROBUSTNESS` otherwise. -@subsubsection window_attribs_fb Framebuffer related attributes +#### Framebuffer related attributes {#window_attribs_fb} GLFW does not expose most attributes of the default framebuffer (i.e. the framebuffer attached to the window) as these can be queried directly with either @@ -1453,7 +1453,7 @@ when rendering with OpenGL or OpenGL ES. This can be set before creation with the [GLFW_DOUBLEBUFFER](@ref GLFW_DOUBLEBUFFER_hint) window hint. -@section buffer_swap Buffer swapping +## Buffer swapping {#buffer_swap} GLFW windows are by default double buffered. That means that you have two rendering buffers; a front buffer and a back buffer. The front buffer is From 1a0bae7fa8e8207518c960d2179155fd79aa04a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Feb 2024 20:57:45 +0100 Subject: [PATCH 080/137] Convert Doxygen code sections to Markdown --- docs/build.md | 64 ++++++------ docs/compile.md | 52 +++++----- docs/context.md | 52 +++++----- docs/input.md | 224 ++++++++++++++++++++-------------------- docs/intro.md | 76 +++++++------- docs/monitor.md | 56 +++++----- docs/moving.md | 88 ++++++++-------- docs/news.md | 4 +- docs/quick.md | 80 +++++++-------- docs/vulkan.md | 48 ++++----- docs/window.md | 268 ++++++++++++++++++++++++------------------------ 11 files changed, 506 insertions(+), 506 deletions(-) diff --git a/docs/build.md b/docs/build.md index 43f351d1..06085431 100644 --- a/docs/build.md +++ b/docs/build.md @@ -19,9 +19,9 @@ the documentation for your development environment. You should include the GLFW header in the source files where you use OpenGL or GLFW. -@code{.c} +```c #include -@endcode +``` 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 @@ -48,10 +48,10 @@ 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{.c} +```c #include #include -@endcode +``` 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 @@ -59,11 +59,11 @@ macro. If yours doesn't or you don't know which one your users will pick, the including the OpenGL header. This will also allow you to include the two headers in any order. -@code{.c} +```c #define GLFW_INCLUDE_NONE #include #include -@endcode +``` ### GLFW header option macros {#build_macros} @@ -186,18 +186,18 @@ built along with your application. Add the root directory of the GLFW source tree to your project. This will add the `glfw` target to your project. -@code{.cmake} +```cmake add_subdirectory(path/to/glfw) -@endcode +``` 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} +```cmake target_link_libraries(myapp glfw) -@endcode +``` 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 @@ -205,16 +205,16 @@ OpenGL directly, instead of using a modern [extension loader library](@ref context_glext_auto), use the OpenGL CMake package. -@code{.cmake} +```cmake 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 any other library. -@code{.cmake} +```cmake 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. @@ -229,17 +229,17 @@ installed. If you want to build it along with your application instead, see With a few changes to your `CMakeLists.txt` you can locate the package and target files generated when GLFW is installed. -@code{.cmake} +```cmake find_package(glfw3 3.4 REQUIRED) -@endcode +``` Once GLFW has been added to the project, link against it with the `glfw` target. 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} +```cmake target_link_libraries(myapp glfw) -@endcode +``` 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 @@ -247,16 +247,16 @@ OpenGL directly, instead of using a modern [extension loader library](@ref context_glext_auto), use the OpenGL CMake package. -@code{.cmake} +```cmake 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 any other library. -@code{.cmake} +```cmake target_link_libraries(myapp OpenGL::GL) -@endcode +``` ### With makefiles and pkg-config on Unix {#build_link_pkgconfig} @@ -271,23 +271,23 @@ ones automatically. A typical compile and link command-line when using the static version of the GLFW library may look like this: -@code{.sh} +```sh 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} +```sh 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} +```sh 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, as GLFW loads any OpenGL, OpenGL ES or Vulkan libraries it needs at runtime. If your application calls OpenGL @@ -295,9 +295,9 @@ directly, instead of using a modern [extension loader library](@ref context_glext_auto), you should add the `gl` pkg-config package. -@code{.sh} +```sh cc $(pkg-config --cflags glfw3 gl) -o myprog myprog.c $(pkg-config --libs glfw3 gl) -@endcode +``` ### With Xcode on macOS {#build_link_xcode} @@ -320,9 +320,9 @@ the `-l` and `-framework` switches. If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do: -@code{.sh} +```sh 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` for `-lglfw`. diff --git a/docs/compile.md b/docs/compile.md index cc3c8991..70dba5ff 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -55,27 +55,27 @@ On Debian and derivatives like Ubuntu and Linux Mint you will need the `libwayla and `libxkbcommon-dev` packages to compile for Wayland and the `xorg-dev` meta-package to compile for X11. These will pull in all other dependencies. -@code{.sh} +```sh sudo apt install libwayland-dev libxkbcommon-dev xorg-dev -@endcode +``` On Fedora and derivatives like Red Hat you will need the `wayland-devel` and `libxkbcommon-devel` packages to compile for Wayland and the `libXcursor-devel`, `libXi-devel`, `libXinerama-devel` and `libXrandr-devel` packages to compile for X11. These will pull in all other dependencies. -@code{.sh} +```sh sudo dnf install wayland-devel libxkbcommon-devel libXcursor-devel libXi-devel libXinerama-devel libXrandr-devel -@endcode +``` On FreeBSD you will need the `wayland`, `libxkbcommon` and `evdev-proto` packages to compile for Wayland. The X11 headers are installed along the end-user X11 packages, so if you have an X server running you should have the headers as well. If not, install the `xorgproto` package to compile for X11. -@code{.sh} +```sh pkg install wayland libxkbcommon evdev-proto xorgproto -@endcode +``` On Cygwin Wayland is not supported but you will need the `libXcursor-devel`, `libXi-devel`, `libXinerama-devel`, `libXrandr-devel` and `libXrender-devel` packages to @@ -131,33 +131,33 @@ To make a build directory, pass the source and build directories to the `cmake` command. These can be relative or absolute paths. The build directory is created if it doesn't already exist. -@code{.sh} +```sh cmake -S path/to/glfw -B path/to/build -@endcode +``` It is common to name the build directory `build` and place it in the root of the source tree when only planning to build a single configuration. -@code{.sh} +```sh cd path/to/glfw cmake -S . -B build -@endcode +``` Without other flags these will generate Visual Studio project files on Windows and makefiles on other platforms. You can choose other targets using the `-G` flag. -@code{.sh} +```sh cmake -S path/to/glfw -B path/to/build -G Xcode -@endcode +``` By default, GLFW will use Wayland and X11 on Linux and other Unix-like systems other than macOS. To disable support for one or both of these, set the @ref GLFW_BUILD_WAYLAND and/or @ref GLFW_BUILD_X11 CMake option. -@code{.sh} +```sh cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_X11=0 -@endcode +``` Once you have generated the project files or makefiles for your chosen development environment, move on to @ref compile_compile. @@ -174,24 +174,24 @@ With Visual Studio open `GLFW.sln` and use the Build menu. With Xcode open With Linux, macOS and other forms of Unix, run `make`. -@code{.sh} +```sh cd path/to/build make -@endcode +``` With MinGW, it is `mingw32-make`. -@code{.sh} +```sh cd path/to/build mingw32-make -@endcode +``` Any CMake build directory can also be built with the `cmake` command and the `--build` flag. -@code{.sh} +```sh cmake --build path/to/build -@endcode +``` This will run the platform specific build tool the directory was generated for. @@ -214,9 +214,9 @@ distributions based on Debian GNU/Linux have this tool in a separate Finally, if you don't want to use any GUI, you can set options from the `cmake` command-line with the `-D` flag. -@code{.sh} +```sh cmake -S path/to/glfw -B path/to/build -D BUILD_SHARED_LIBS=ON -@endcode +``` ### Shared CMake options {#compile_options_shared} @@ -309,9 +309,9 @@ cross-compilation of Windows binaries. To use these files you set the `CMAKE_TOOLCHAIN_FILE` CMake variable with the `-D` flag add an option when configuring and generating the build files. -@code{.sh} +```sh cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file -@endcode +``` The exact toolchain file to use depends on the prefix used by the MinGW or MinGW-w64 binaries on your system. You can usually see this in the /usr @@ -319,9 +319,9 @@ directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have `/usr/x86_64-w64-mingw32` for the 64-bit compilers, so the correct invocation would be: -@code{.sh} +```sh cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64-mingw32.cmake -@endcode +``` The path to the toolchain file is relative to the path to the GLFW source tree passed to the `-S` flag, not to the current directory. diff --git a/docs/context.md b/docs/context.md index c900a8bb..755addde 100644 --- a/docs/context.md +++ b/docs/context.md @@ -45,9 +45,9 @@ When creating a window and its OpenGL or OpenGL ES context with @ref glfwCreateWindow, you can specify another window whose context the new one should share its objects (textures, vertex and element buffers, etc.) with. -@code{.c} +```c GLFWwindow* second_window = glfwCreateWindow(640, 480, "Second Window", NULL, first_window); -@endcode +``` Object sharing is implemented by the operating system and graphics driver. On platforms where it is possible to choose which types of objects are shared, GLFW @@ -68,11 +68,11 @@ GLFW doesn't support creating contexts without an associated window. However, contexts with hidden windows can be created with the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint. -@code{.c} +```c glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); GLFWwindow* offscreen_context = glfwCreateWindow(640, 480, "", NULL, NULL); -@endcode +``` The window never needs to be shown and its context can be used as a plain offscreen context. Depending on the window manager, the size of a hidden @@ -103,15 +103,15 @@ thread before making it current on the new one. The context of a window is made current with @ref glfwMakeContextCurrent. -@code{.c} +```c glfwMakeContextCurrent(window); -@endcode +``` The window of the current context is returned by @ref glfwGetCurrentContext. -@code{.c} +```c GLFWwindow* window = glfwGetCurrentContext(); -@endcode +``` The following GLFW functions require a context to be current. Calling any these functions without a current context will generate a @ref GLFW_NO_CURRENT_CONTEXT @@ -167,9 +167,9 @@ both GLFW and glad, but loaders for OpenGL ES, as well as loaders for specific API versions and extension sets can be generated. The generated files are written to the `output` directory. -@code{.sh} +```sh python main.py --generator c --no-loader --out-path output -@endcode +``` The `--no-loader` option is added because GLFW already provides a function for loading OpenGL and OpenGL ES function pointers, one that automatically uses the @@ -183,14 +183,14 @@ include the glad header file, which will replace the OpenGL header of your development environment. By including the glad header before the GLFW header, it suppresses the development environment's OpenGL or OpenGL ES header. -@code{.c} +```c #include #include -@endcode +``` Finally, you need to initialize glad once you have a suitable current context. -@code{.c} +```c window = glfwCreateWindow(640, 480, "My Window", NULL, NULL); if (!window) { @@ -200,7 +200,7 @@ if (!window) glfwMakeContextCurrent(window); gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); -@endcode +``` Once glad has been loaded, you have access to all OpenGL core and extension functions supported by both the context you created and the glad loader you @@ -213,22 +213,22 @@ check the actual OpenGL or OpenGL ES version with a specific version is supported by the current context with the `GLAD_GL_VERSION_x_x` booleans. -@code{.c} +```c if (GLAD_GL_VERSION_3_2) { // Call OpenGL 3.2+ specific code } -@endcode +``` To check whether a specific extension is supported, use the `GLAD_GL_xxx` booleans. -@code{.c} +```c if (GLAD_GL_ARB_gl_spirv) { // Use GL_ARB_gl_spirv } -@endcode +``` ### Loading extensions manually {#context_glext_manual} @@ -265,10 +265,10 @@ to function) and `PROC` (procedure) are added to the ends. To include the extension header, define @ref GLFW_INCLUDE_GLEXT before including the GLFW header. -@code{.c} +```c #define GLFW_INCLUDE_GLEXT #include -@endcode +``` #### Checking for extensions {#context_glext_string} @@ -278,12 +278,12 @@ drivers or a graphics card that lacks the necessary hardware features), so it is necessary to check at run-time whether the context supports the extension. This is done with @ref glfwExtensionSupported. -@code{.c} +```c if (glfwExtensionSupported("GL_ARB_gl_spirv")) { // The extension is supported by the current context } -@endcode +``` The argument is a null terminated ASCII string with the extension name. If the extension is supported, @ref glfwExtensionSupported returns `GLFW_TRUE`, @@ -297,9 +297,9 @@ These functions often do not have entry points in the client API libraries of your operating system, making it necessary to fetch them at run time. You can retrieve pointers to these functions with @ref glfwGetProcAddress. -@code{.c} +```c PFNGLSPECIALIZESHADERARBPROC pfnSpecializeShaderARB = glfwGetProcAddress("glSpecializeShaderARB"); -@endcode +``` In general, you should avoid giving the function pointer variables the (exact) same name as the function, as this may confuse your linker. Instead, you can @@ -308,7 +308,7 @@ use a different prefix, like above, or some other naming scheme. Now that all the pieces have been introduced, here is what they might look like when used together. -@code{.c} +```c #define GLFW_INCLUDE_GLEXT #include @@ -336,5 +336,5 @@ void some_function(void) glSpecializeShaderARB(...); } } -@endcode +``` diff --git a/docs/input.md b/docs/input.md index bc5cc461..c11e7c61 100644 --- a/docs/input.md +++ b/docs/input.md @@ -40,18 +40,18 @@ There are three functions for processing pending events. @ref glfwPollEvents, processes only those events that have already been received and then returns immediately. -@code{.c} +```c glfwPollEvents(); -@endcode +``` This is the best choice when rendering continuously, like most games do. If you only need to update the contents of the window when you receive new input, @ref glfwWaitEvents is a better choice. -@code{.c} +```c glfwWaitEvents(); -@endcode +``` It puts the thread to sleep until at least one event has been received and then processes all received events. This saves a great deal of CPU cycles and is @@ -60,9 +60,9 @@ useful for, for example, editing tools. If you want to wait for events but have UI elements or other tasks that need periodic updates, @ref glfwWaitEventsTimeout lets you specify a timeout. -@code{.c} +```c glfwWaitEventsTimeout(0.7); -@endcode +``` It puts the thread to sleep until at least one event has been received, or until the specified number of seconds have elapsed. It then processes any received @@ -72,9 +72,9 @@ If the main thread is sleeping in @ref glfwWaitEvents, you can wake it from another thread by posting an empty event to the event queue with @ref glfwPostEmptyEvent. -@code{.c} +```c glfwPostEmptyEvent(); -@endcode +``` Do not assume that callbacks will _only_ be called in response to the above functions. While it is necessary to process events in one or more of the ways @@ -106,20 +106,20 @@ same keyboard layout, input method or even operating system as you. If you wish to be notified when a physical key is pressed or released or when it repeats, set a key callback. -@code{.c} +```c glfwSetKeyCallback(window, key_callback); -@endcode +``` The callback function receives the [keyboard key](@ref keys), platform-specific scancode, key action and [modifier bits](@ref mods). -@code{.c} +```c void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_E && action == GLFW_PRESS) activate_airship(); } -@endcode +``` The action is one of `GLFW_PRESS`, `GLFW_REPEAT` or `GLFW_RELEASE`. Events with `GLFW_PRESS` and `GLFW_RELEASE` actions are emitted for every key press. Most @@ -147,21 +147,21 @@ different scancodes depending on the platform but they are safe to save to disk. You can query the scancode for any [key token](@ref keys) supported on the current platform with @ref glfwGetKeyScancode. -@code{.c} +```c const int scancode = glfwGetKeyScancode(GLFW_KEY_X); set_key_mapping(scancode, swap_weapons); -@endcode +``` The last reported state for every physical key with a [key token](@ref keys) is also saved in per-window state arrays that can be polled with @ref glfwGetKey. -@code{.c} +```c int state = glfwGetKey(window, GLFW_KEY_E); if (state == GLFW_PRESS) { activate_airship(); } -@endcode +``` The returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`. @@ -175,9 +175,9 @@ If a pressed key is released again before you poll its state, you will have missed the key press. The recommended solution for this is to use a key callback, but there is also the `GLFW_STICKY_KEYS` input mode. -@code{.c} +```c glfwSetInputMode(window, GLFW_STICKY_KEYS, GLFW_TRUE); -@endcode +``` When sticky keys mode is enabled, the pollable state of a key will remain `GLFW_PRESS` until the state of that key is polled with @ref glfwGetKey. Once @@ -188,9 +188,9 @@ the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`. If you wish to know what the state of the Caps Lock and Num Lock keys was when input events were generated, set the `GLFW_LOCK_KEY_MODS` input mode. -@code{.c} +```c glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, GLFW_TRUE); -@endcode +``` When this input mode is enabled, any callback that receives [modifier bits](@ref mods) will have the @ref GLFW_MOD_CAPS_LOCK bit set if Caps @@ -215,19 +215,19 @@ you can treat the code point argument as native endian UTF-32. If you wish to offer regular text input, set a character callback. -@code{.c} +```c glfwSetCharCallback(window, character_callback); -@endcode +``` The callback function receives Unicode code points for key events that would have led to regular text input and generally behaves as a standard text field on that platform. -@code{.c} +```c void character_callback(GLFWwindow* window, unsigned int codepoint) { } -@endcode +``` ### Key names {#input_key_name} @@ -235,10 +235,10 @@ void character_callback(GLFWwindow* window, unsigned int codepoint) If you wish to refer to keys by name, you can query the keyboard layout dependent name of printable keys with @ref glfwGetKeyName. -@code{.c} +```c const char* key_name = glfwGetKeyName(GLFW_KEY_W, 0); show_tutorial_hint("Press %s to move forward", key_name); -@endcode +``` This function can handle both [keys and scancodes](@ref input_key). If the specified key is `GLFW_KEY_UNKNOWN` then the scancode is used, otherwise it is @@ -258,27 +258,27 @@ a custom image or a standard cursor shape from the system theme. If you wish to be notified when the cursor moves over the window, set a cursor position callback. -@code{.c} +```c glfwSetCursorPosCallback(window, cursor_position_callback); -@endcode +``` The callback functions receives the cursor position, measured in screen coordinates but relative to the top-left corner of the window content area. On platforms that provide it, the full sub-pixel cursor position is passed on. -@code{.c} +```c static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos) { } -@endcode +``` The cursor position is also saved per-window and can be polled with @ref glfwGetCursorPos. -@code{.c} +```c double xpos, ypos; glfwGetCursorPos(window, &xpos, &ypos); -@endcode +``` ### Cursor mode {#cursor_mode} @@ -293,9 +293,9 @@ If you wish to implement mouse motion based camera controls or other input schemes that require unlimited mouse movement, set the cursor mode to `GLFW_CURSOR_DISABLED`. -@code{.c} +```c glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); -@endcode +``` This will hide the cursor and lock it to the specified window. GLFW will then take care of all the details of cursor re-centering and offset calculation and @@ -309,18 +309,18 @@ other features of GLFW. It is not supported and will not work as robustly as If you only wish the cursor to become hidden when it is over a window but still want it to behave normally, set the cursor mode to `GLFW_CURSOR_HIDDEN`. -@code{.c} +```c glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); -@endcode +``` This mode puts no limit on the motion of the cursor. If you wish the cursor to be visible but confined to the content area of the window, set the cursor mode to `GLFW_CURSOR_CAPTURED`. -@code{.c} +```c glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_CAPTURED); -@endcode +``` The cursor will behave normally inside the content area but will not be able to leave unless the window loses focus. @@ -328,9 +328,9 @@ leave unless the window loses focus. To exit out of either of these special modes, restore the `GLFW_CURSOR_NORMAL` cursor mode. -@code{.c} +```c glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); -@endcode +``` If the cursor was disabled, this will move it back to its last visible position. @@ -351,10 +351,10 @@ Call @ref glfwRawMouseMotionSupported to check if the current machine provides raw motion and set the `GLFW_RAW_MOUSE_MOTION` input mode to enable it. It is disabled by default. -@code{.c} +```c if (glfwRawMouseMotionSupported()) glfwSetInputMode(window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE); -@endcode +``` If supported, raw mouse motion can be enabled or disabled per-window and at any time but it will only be provided when the cursor is disabled. @@ -374,7 +374,7 @@ A custom cursor is created with @ref glfwCreateCursor, which returns a handle to the created cursor object. For example, this creates a 16x16 white square cursor with the hot-spot in the upper-left corner: -@code{.c} +```c unsigned char pixels[16 * 16 * 4]; memset(pixels, 0xff, sizeof(pixels)); @@ -384,7 +384,7 @@ image.height = 16; image.pixels = pixels; GLFWcursor* cursor = glfwCreateCursor(&image, 0, 0); -@endcode +``` If cursor creation fails, `NULL` will be returned, so it is necessary to check the return value. @@ -399,9 +399,9 @@ sequential rows, starting from the top-left corner. A cursor with a [standard shape](@ref shapes) from the current system cursor theme can be created with @ref glfwCreateStandardCursor. -@code{.c} +```c 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. @@ -414,9 +414,9 @@ A few of these shapes are not available everywhere. If a shape is unavailable, When a cursor is no longer needed, destroy it with @ref glfwDestroyCursor. -@code{.c} +```c glfwDestroyCursor(cursor); -@endcode +``` Cursor destruction always succeeds. If the cursor is current for any window, that window will revert to the default cursor. This does not affect the cursor @@ -427,9 +427,9 @@ mode. All remaining cursors are destroyed when @ref glfwTerminate is called. A cursor can be set as current for a window with @ref glfwSetCursor. -@code{.c} +```c glfwSetCursor(window, cursor); -@endcode +``` Once set, the cursor image will be used as long as the system cursor is over the content area of the window and the [cursor mode](@ref cursor_mode) is set @@ -439,9 +439,9 @@ A single cursor may be set for any number of windows. To revert to the default cursor, set the cursor of that window to `NULL`. -@code{.c} +```c glfwSetCursor(window, NULL); -@endcode +``` When a cursor is destroyed, any window that has it set will revert to the default cursor. This does not affect the cursor mode. @@ -452,13 +452,13 @@ default cursor. This does not affect the cursor mode. If you wish to be notified when the cursor enters or leaves the content area of a window, set a cursor enter/leave callback. -@code{.c} +```c glfwSetCursorEnterCallback(window, cursor_enter_callback); -@endcode +``` The callback function receives the new classification of the cursor. -@code{.c} +```c void cursor_enter_callback(GLFWwindow* window, int entered) { if (entered) @@ -470,17 +470,17 @@ void cursor_enter_callback(GLFWwindow* window, int entered) // The cursor left the content area of the window } } -@endcode +``` You can query whether the cursor is currently inside the content area of the window with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute. -@code{.c} +```c if (glfwGetWindowAttrib(window, GLFW_HOVERED)) { highlight_interface(); } -@endcode +``` ### Mouse button input {#input_mouse_button} @@ -488,20 +488,20 @@ if (glfwGetWindowAttrib(window, GLFW_HOVERED)) If you wish to be notified when a mouse button is pressed or released, set a mouse button callback. -@code{.c} +```c glfwSetMouseButtonCallback(window, mouse_button_callback); -@endcode +``` The callback function receives the [mouse button](@ref buttons), button action and [modifier bits](@ref mods). -@code{.c} +```c void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) { if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) popup_menu(); } -@endcode +``` The action is one of `GLFW_PRESS` or `GLFW_RELEASE`. @@ -509,13 +509,13 @@ The last reported state for every [supported mouse button](@ref buttons) is also saved in per-window state arrays that can be polled with @ref glfwGetMouseButton. -@code{.c} +```c int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT); if (state == GLFW_PRESS) { upgrade_cow(); } -@endcode +``` The returned state is one of `GLFW_PRESS` or `GLFW_RELEASE`. @@ -529,9 +529,9 @@ missed the button press. The recommended solution for this is to use a mouse button callback, but there is also the `GLFW_STICKY_MOUSE_BUTTONS` input mode. -@code{.c} +```c glfwSetInputMode(window, GLFW_STICKY_MOUSE_BUTTONS, GLFW_TRUE); -@endcode +``` When sticky mouse buttons mode is enabled, the pollable state of a mouse button will remain `GLFW_PRESS` until the state of that button is polled with @ref @@ -548,17 +548,17 @@ The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any If you wish to be notified when the user scrolls, whether with a mouse wheel or touchpad gesture, set a scroll callback. -@code{.c} +```c glfwSetScrollCallback(window, scroll_callback); -@endcode +``` The callback function receives two-dimensional scroll offsets. -@code{.c} +```c void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { } -@endcode +``` A normal mouse wheel, being vertical, provides offsets along the Y-axis. @@ -571,9 +571,9 @@ referred to as joysticks. It supports up to sixteen joysticks, ranging from `GLFW_JOYSTICK_LAST`. You can test whether a [joystick](@ref joysticks) is present with @ref glfwJoystickPresent. -@code{.c} +```c int present = glfwJoystickPresent(GLFW_JOYSTICK_1); -@endcode +``` Each joystick has zero or more axes, zero or more buttons, zero or more hats, a human-readable name, a user pointer and an SDL compatible GUID. @@ -599,10 +599,10 @@ The positions of all axes of a joystick are returned by @ref glfwGetJoystickAxes. See the reference documentation for the lifetime of the returned array. -@code{.c} +```c int count; const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_5, &count); -@endcode +``` Each element in the returned array is a value between -1.0 and 1.0. @@ -613,10 +613,10 @@ The states of all buttons of a joystick are returned by @ref glfwGetJoystickButtons. See the reference documentation for the lifetime of the returned array. -@code{.c} +```c int count; const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_3, &count); -@endcode +``` Each element in the returned array is either `GLFW_PRESS` or `GLFW_RELEASE`. @@ -630,10 +630,10 @@ the reference documentation for @ref glfwGetJoystickButtons for details. The states of all hats are returned by @ref glfwGetJoystickHats. See the reference documentation for the lifetime of the returned array. -@code{.c} +```c int count; const unsigned char* hats = glfwGetJoystickHats(GLFW_JOYSTICK_7, &count); -@endcode +``` Each element in the returned array is one of the following: @@ -653,12 +653,12 @@ The diagonal directions are bitwise combinations of the primary (up, right, down and left) directions and you can test for these individually by ANDing it with the corresponding direction. -@code{.c} +```c if (hats[2] & GLFW_HAT_RIGHT) { // State of hat 2 could be right-up, right or right-down } -@endcode +``` For backward compatibility with earlier versions that did not have @ref glfwGetJoystickHats, all hats are by default also included in the button array. @@ -671,9 +671,9 @@ The human-readable, UTF-8 encoded name of a joystick is returned by @ref glfwGetJoystickName. See the reference documentation for the lifetime of the returned string. -@code{.c} +```c const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4); -@endcode +``` Joystick names are not guaranteed to be unique. Two joysticks of the same model and make may have the same name. Only the [joystick ID](@ref joysticks) is @@ -696,14 +696,14 @@ The initial value of the pointer is `NULL`. If you wish to be notified when a joystick is connected or disconnected, set a joystick callback. -@code{.c} +```c glfwSetJoystickCallback(joystick_callback); -@endcode +``` The callback function receives the ID of the joystick that has been connected and disconnected and the event that occurred. -@code{.c} +```c void joystick_callback(int jid, int event) { if (event == GLFW_CONNECTED) @@ -715,7 +715,7 @@ void joystick_callback(int jid, int event) // The joystick was disconnected } } -@endcode +``` For joystick connection and disconnection events to be delivered on all platforms, you need to call one of the [event processing](@ref events) @@ -746,12 +746,12 @@ a joystick is connected or the mappings are updated. You can check whether a joystick is both present and has a gamepad mapping with @ref glfwJoystickIsGamepad. -@code{.c} +```c if (glfwJoystickIsGamepad(GLFW_JOYSTICK_2)) { // Use as gamepad } -@endcode +``` If you are only interested in gamepad input you can use this function instead of @ref glfwJoystickPresent. @@ -760,13 +760,13 @@ You can query the human-readable name provided by the gamepad mapping with @ref glfwGetGamepadName. This may or may not be the same as the [joystick name](@ref joystick_name). -@code{.c} +```c const char* name = glfwGetGamepadName(GLFW_JOYSTICK_7); -@endcode +``` To retrieve the gamepad state of a joystick, call @ref glfwGetGamepadState. -@code{.c} +```c GLFWgamepadstate state; if (glfwGetGamepadState(GLFW_JOYSTICK_3, &state)) @@ -778,7 +778,7 @@ if (glfwGetGamepadState(GLFW_JOYSTICK_3, &state)) input_speed(state.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER]); } -@endcode +``` The @ref GLFWgamepadstate struct has two arrays; one for button states and one for axis states. The values for each button and axis are the same as for the @@ -816,11 +816,11 @@ GLFW contains a copy of the mappings available in time of release. Newer ones can be added at runtime with @ref glfwUpdateGamepadMappings. -@code{.c} +```c const char* mappings = load_file_contents("game/data/gamecontrollerdb.txt"); glfwUpdateGamepadMappings(mappings); -@endcode +``` This function supports everything from single lines up to and including the unmodified contents of the whole `gamecontrollerdb.txt` file. @@ -880,12 +880,12 @@ one built into GLFW for Xbox controllers accessed via the XInput API on Windows. This example has been broken into several lines to fit on the page, but real gamepad mappings must be a single line. -@code{.unparsed} +``` 78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0, b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8, rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4, righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8, -@endcode +``` @note GLFW does not yet support the output range and modifiers `+` and `-` that were recently added to SDL. The input modifiers `+`, `-` and `~` are supported @@ -896,9 +896,9 @@ and described above. GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime. -@code{.c} +```c double seconds = glfwGetTime(); -@endcode +``` It returns the number of seconds since the library was initialized with @ref glfwInit. The platform-specific time sources used typically have micro- or @@ -906,9 +906,9 @@ nanosecond resolution. You can modify the base time with @ref glfwSetTime. -@code{.c} +```c glfwSetTime(4.0); -@endcode +``` This sets the time to the specified time, in seconds, and it continues to count from there. @@ -916,17 +916,17 @@ from there. You can also access the raw timer used to implement the functions above, with @ref glfwGetTimerValue. -@code{.c} +```c uint64_t value = glfwGetTimerValue(); -@endcode +``` 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{.c} +```c uint64_t frequency = glfwGetTimerFrequency(); -@endcode +``` ## Clipboard input and output {#clipboard} @@ -935,13 +935,13 @@ If the system clipboard contains a UTF-8 encoded string or if it can be converted to one, you can retrieve it with @ref glfwGetClipboardString. See the reference documentation for the lifetime of the returned string. -@code{.c} +```c const char* text = glfwGetClipboardString(NULL); if (text) { insert_text(text); } -@endcode +``` If the clipboard is empty or if its contents could not be converted, `NULL` is returned. @@ -949,9 +949,9 @@ returned. The contents of the system clipboard can be set to a UTF-8 encoded string with @ref glfwSetClipboardString. -@code{.c} +```c glfwSetClipboardString(NULL, "A string with words in it"); -@endcode +``` ## Path drop input {#path_drop} @@ -959,20 +959,20 @@ glfwSetClipboardString(NULL, "A string with words in it"); If you wish to receive the paths of files and/or directories dropped on a window, set a file drop callback. -@code{.c} +```c glfwSetDropCallback(window, drop_callback); -@endcode +``` The callback function receives an array of paths encoded as UTF-8. -@code{.c} +```c void drop_callback(GLFWwindow* window, int count, const char** paths) { int i; for (i = 0; i < count; i++) handle_dropped_file(paths[i]); } -@endcode +``` The path array and its strings are only valid until the file drop callback returns, as they may have been generated specifically for that event. You need diff --git a/docs/intro.md b/docs/intro.md index 35334c7b..aa3bed01 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -46,12 +46,12 @@ GLFW_NOT_INITIALIZED error. The library is initialized with @ref glfwInit, which returns `GLFW_FALSE` if an error occurred. -@code{.c} +```c if (!glfwInit()) { // Handle initialization failure } -@endcode +``` If any part of initialization fails, any parts that succeeded are terminated as if @ref glfwTerminate had been called. The library only needs to be initialized @@ -74,9 +74,9 @@ hint. Initialization hints are set before @ref glfwInit and affect how the library behaves until termination. Hints are set with @ref glfwInitHint. -@code{.c} +```c glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE); -@endcode +``` The values you set hints to are never reset by GLFW, but they only take effect during initialization. Once GLFW has been initialized, any values you set will @@ -174,32 +174,32 @@ default, this is set to @ref GLFW_ANY_PLATFORM, which will look for supported wi systems in order of priority and select the first one it finds. It can also be set to any specific platform to have GLFW only look for that one. -@code{.c} +```c glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_X11); -@endcode +``` This mechanism also provides the Null platform, which is always supported but needs to be explicitly requested. This platform is effectively a stub, emulating a window system on a single 1080p monitor, but will not interact with any actual window system. -@code{.c} +```c glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL); -@endcode +``` You can test whether a library binary was compiled with support for a specific platform with @ref glfwPlatformSupported. -@code{.c} +```c if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND); -@endcode +``` Once GLFW has been initialized, you can query which platform was selected with @ref glfwGetPlatform. -@code{.c} +```c int platform = glfwGetPlatform(); -@endcode +``` If you are using any [native access functions](@ref native), especially on Linux and other Unix-like systems, then you may need to check that you are calling the ones matching the @@ -211,7 +211,7 @@ selected platform. The heap memory allocator can be customized before initialization with @ref glfwInitAllocator. -@code{.c} +```c GLFWallocator allocator; allocator.allocate = my_malloc; allocator.reallocate = my_realloc; @@ -219,7 +219,7 @@ allocator.deallocate = my_free; allocator.user = NULL; glfwInitAllocator(&allocator); -@endcode +``` The allocator will be made active at the beginning of initialization and will be used by GLFW until the library has been fully terminated. Any allocator set after initialization @@ -233,12 +233,12 @@ The allocation function must have a signature matching @ref GLFWallocatefun. It the desired size, in bytes, and the user pointer passed to @ref glfwInitAllocator and returns the address to the allocated memory block. -@code{.c} +```c void* my_malloc(size_t size, void* user) { ... } -@endcode +``` The documentation for @ref GLFWallocatefun also lists the requirements and limitations for an allocation function. If the active one does not meet all of these, GLFW may fail. @@ -248,12 +248,12 @@ It receives the memory block to be reallocated, the new desired size, in bytes, pointer passed to @ref glfwInitAllocator and returns the address to the resized memory block. -@code{.c} +```c void* my_realloc(void* block, size_t size, void* user) { ... } -@endcode +``` The documentation for @ref GLFWreallocatefun also lists the requirements and limitations for a reallocation function. If the active one does not meet all of these, GLFW may fail. @@ -262,12 +262,12 @@ The deallocation function must have a function signature matching @ref GLFWdeall It receives the memory block to be deallocated and the user pointer passed to @ref glfwInitAllocator. -@code{.c} +```c void my_free(void* block, void* user) { ... } -@endcode +``` The documentation for @ref GLFWdeallocatefun also lists the requirements and limitations for a deallocation function. If the active one does not meet all of these, GLFW may fail. @@ -278,9 +278,9 @@ for a deallocation function. If the active one does not meet all of these, GLFW Before your application exits, you should terminate the GLFW library if it has been initialized. This is done with @ref glfwTerminate. -@code{.c} +```c glfwTerminate(); -@endcode +``` This will destroy any remaining window, monitor and cursor objects, restore any modified gamma ramps, re-enable the screensaver if it had been disabled and free @@ -303,12 +303,12 @@ values. The last [error code](@ref errors) for the calling thread can be queried at any time with @ref glfwGetError. -@code{.c} +```c int code = glfwGetError(NULL); if (code != GLFW_NO_ERROR) handle_error(code); -@endcode +``` If no error has occurred since the last call, @ref GLFW_NO_ERROR (zero) is returned. The error is cleared before the function returns. @@ -322,13 +322,13 @@ can retrieve a UTF-8 encoded human-readable description along with the error code. If no error has occurred since the last call, the description is set to `NULL`. -@code{.c} +```c const char* description; int code = glfwGetError(&description); if (description) display_error_message(code, description); -@endcode +``` The retrieved description string is only valid until the next error occurs. This means you must make a copy of it if you want to keep it. @@ -336,19 +336,19 @@ This means you must make a copy of it if you want to keep it. You can also set an error callback, which will be called each time an error occurs. It is set with @ref glfwSetErrorCallback. -@code{.c} +```c glfwSetErrorCallback(error_callback); -@endcode +``` The error callback receives the same error code and human-readable description returned by @ref glfwGetError. -@code{.c} +```c void error_callback(int code, const char* description) { display_error_message(code, description); } -@endcode +``` The error callback is called after the error is stored, so calling @ref glfwGetError from within the error callback returns the same values as the @@ -570,12 +570,12 @@ this to verify that the library binary is compatible with your application. The compile-time version of GLFW is provided by the GLFW header with the `GLFW_VERSION_MAJOR`, `GLFW_VERSION_MINOR` and `GLFW_VERSION_REVISION` macros. -@code{.c} +```c printf("Compiled against GLFW %i.%i.%i\n", GLFW_VERSION_MAJOR, GLFW_VERSION_MINOR, GLFW_VERSION_REVISION); -@endcode +``` ### Run-time version {#intro_version_runtime} @@ -583,12 +583,12 @@ printf("Compiled against GLFW %i.%i.%i\n", The run-time version can be retrieved with @ref glfwGetVersion, a function that may be called regardless of whether GLFW is initialized. -@code{.c} +```c int major, minor, revision; glfwGetVersion(&major, &minor, &revision); printf("Running against GLFW %i.%i.%i\n", major, minor, revision); -@endcode +``` ### Version string {#intro_version_string} @@ -622,14 +622,14 @@ The format of the string is as follows: For example, compiling GLFW 3.4 with MinGW as a DLL for Windows, may result in a version string like this: -@code{.c} +```c 3.4.0 Win32 WGL Null EGL OSMesa MinGW DLL -@endcode +``` Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may result in a version string like this: -@code{.c} +```c 3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic -@endcode +``` diff --git a/docs/monitor.md b/docs/monitor.md index b4ba75c4..27cf6793 100644 --- a/docs/monitor.md +++ b/docs/monitor.md @@ -40,17 +40,17 @@ The primary monitor is returned by @ref glfwGetPrimaryMonitor. It is the user's preferred monitor and is usually the one with global UI elements like task bar or menu bar. -@code{.c} +```c GLFWmonitor* primary = glfwGetPrimaryMonitor(); -@endcode +``` You can retrieve all currently connected monitors with @ref glfwGetMonitors. See the reference documentation for the lifetime of the returned array. -@code{.c} +```c int count; GLFWmonitor** monitors = glfwGetMonitors(&count); -@endcode +``` The primary monitor is always the first monitor in the returned array, but other monitors may be moved to a different index when a monitor is connected or @@ -62,14 +62,14 @@ disconnected. If you wish to be notified when a monitor is connected or disconnected, set a monitor callback. -@code{.c} +```c glfwSetMonitorCallback(monitor_callback); -@endcode +``` The callback function receives the handle for the monitor that has been connected or disconnected and the event that occurred. -@code{.c} +```c void monitor_callback(GLFWmonitor* monitor, int event) { if (event == GLFW_CONNECTED) @@ -81,7 +81,7 @@ void monitor_callback(GLFWmonitor* monitor, int event) // The monitor was disconnected } } -@endcode +``` If a monitor is disconnected, all windows that are full screen on it will be switched to windowed mode before the callback is called. Only @ref @@ -107,17 +107,17 @@ Video modes are represented as @ref GLFWvidmode structures. You can get an array of the video modes supported by a monitor with @ref glfwGetVideoModes. See the reference documentation for the lifetime of the returned array. -@code{.c} +```c int count; GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); -@endcode +``` To get the current video mode of a monitor call @ref glfwGetVideoMode. See the reference documentation for the lifetime of the returned pointer. -@code{.c} +```c const GLFWvidmode* mode = glfwGetVideoMode(monitor); -@endcode +``` The resolution of a video mode is specified in [screen coordinates](@ref coordinate_systems), not pixels. @@ -130,10 +130,10 @@ retrieved with @ref glfwGetMonitorPhysicalSize. This has no relation to its current _resolution_, i.e. the width and height of its current [video mode](@ref monitor_modes). -@code{.c} +```c int width_mm, height_mm; glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm); -@endcode +``` While this can be used to calculate the raw DPI of a monitor, this is often not useful. Instead, use the [monitor content scale](@ref monitor_scale) and @@ -145,10 +145,10 @@ useful. Instead, use the [monitor content scale](@ref monitor_scale) and The content scale for a monitor can be retrieved with @ref glfwGetMonitorContentScale. -@code{.c} +```c float xscale, yscale; glfwGetMonitorContentScale(monitor, &xscale, &yscale); -@endcode +``` The content scale is the ratio between the current DPI and the platform's default DPI. This is especially important for text and any UI elements. If the @@ -168,10 +168,10 @@ The position of the monitor on the virtual desktop, in [screen coordinates](@ref coordinate_systems), can be retrieved with @ref glfwGetMonitorPos. -@code{.c} +```c int xpos, ypos; glfwGetMonitorPos(monitor, &xpos, &ypos); -@endcode +``` ### Work area {#monitor_workarea} @@ -180,10 +180,10 @@ The area of a monitor not occupied by global task bars or menu bars is the work area. This is specified in [screen coordinates](@ref coordinate_systems) and can be retrieved with @ref glfwGetMonitorWorkarea. -@code{.c} +```c int xpos, ypos, width, height; glfwGetMonitorWorkarea(monitor, &xpos, &ypos, &width, &height); -@endcode +``` ### Human-readable name {#monitor_name} @@ -192,9 +192,9 @@ The human-readable, UTF-8 encoded name of a monitor is returned by @ref glfwGetMonitorName. See the reference documentation for the lifetime of the returned string. -@code{.c} +```c const char* name = glfwGetMonitorName(monitor); -@endcode +``` Monitor names are not guaranteed to be unique. Two monitors of the same model and make may have the same name. Only the monitor handle is guaranteed to be @@ -217,7 +217,7 @@ The initial value of the pointer is `NULL`. The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts a monitor handle and a pointer to a @ref GLFWgammaramp structure. -@code{.c} +```c GLFWgammaramp ramp; unsigned short red[256], green[256], blue[256]; @@ -232,7 +232,7 @@ for (i = 0; i < ramp.size; i++) } glfwSetGammaRamp(monitor, &ramp); -@endcode +``` The gamma ramp data is copied before the function returns, so there is no need to keep it around once the ramp has been set. @@ -243,17 +243,17 @@ ramp for that monitor. The current gamma ramp for a monitor is returned by @ref glfwGetGammaRamp. See the reference documentation for the lifetime of the returned structure. -@code{.c} +```c const GLFWgammaramp* ramp = glfwGetGammaRamp(monitor); -@endcode +``` If you wish to set a regular gamma ramp, you can have GLFW calculate it for you from the desired exponent with @ref glfwSetGamma, which in turn calls @ref glfwSetGammaRamp with the resulting ramp. -@code{.c} +```c glfwSetGamma(monitor, 1.0); -@endcode +``` To experiment with gamma correction via the @ref glfwSetGamma function, run the `gamma` test program. diff --git a/docs/moving.md b/docs/moving.md index 86068dbe..ace4ebdf 100644 --- a/docs/moving.md +++ b/docs/moving.md @@ -20,14 +20,14 @@ Unix-like systems, where it uses the [soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`. @par Old syntax -@code{.c} +```c #include -@endcode +``` @par New syntax -@code{.c} +```c #include -@endcode +``` ### Removal of threading functions {#moving_threads} @@ -93,14 +93,14 @@ the creation of DLLs and DLL link libraries, as there's no need to explicitly disable `@n` entry point suffixes. @par Old syntax -@code{.c} +```c void GLFWCALL callback_function(...); -@endcode +``` @par New syntax -@code{.c} +```c void callback_function(...); -@endcode +``` ### Window handle parameters {#moving_window_handles} @@ -112,14 +112,14 @@ a newly created window is returned by @ref glfwCreateWindow (formerly [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow. @par Old syntax -@code{.c} +```c glfwSetWindowTitle("New Window Title"); -@endcode +``` @par New syntax -@code{.c} +```c glfwSetWindowTitle(window, "New Window Title"); -@endcode +``` ### Explicit monitor selection {#moving_monitor} @@ -132,14 +132,14 @@ GLFW 2 would have selected, but there are many other [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor. @par Old basic full screen -@code{.c} +```c glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN); -@endcode +``` @par New basic full screen -@code{.c} +```c window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL); -@endcode +``` @note The framebuffer bit depth parameters of `glfwOpenWindow` have been turned into [window hints](@ref window_hints), but as they have been given @@ -154,17 +154,17 @@ buffer swap, which acts on a single window, the event processing functions act on all windows at once. @par Old basic main loop -@code{.c} +```c while (...) { // Process input // Render output glfwSwapBuffers(); } -@endcode +``` @par New basic main loop -@code{.c} +```c while (...) { // Process input @@ -172,7 +172,7 @@ while (...) glfwSwapBuffers(window); glfwPollEvents(); } -@endcode +``` ### Explicit context management {#moving_context} @@ -196,16 +196,16 @@ glfwGetFramebufferSize function. A framebuffer size callback has also been added, which can be set with @ref glfwSetFramebufferSizeCallback. @par Old basic viewport setup -@code{.c} +```c glfwGetWindowSize(&width, &height); glViewport(0, 0, width, height); -@endcode +``` @par New basic viewport setup -@code{.c} +```c glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); -@endcode +``` ### Window closing changes {#moving_window_close} @@ -225,20 +225,20 @@ You can query the close flag at any time with @ref glfwWindowShouldClose and set it at any time with @ref glfwSetWindowShouldClose. @par Old basic main loop -@code{.c} +```c while (glfwGetWindowParam(GLFW_OPENED)) { ... } -@endcode +``` @par New basic main loop -@code{.c} +```c while (!glfwWindowShouldClose(window)) { ... } -@endcode +``` The close callback no longer returns a value. Instead, it is called after the close flag has been set, so it can optionally override its value, before @@ -246,14 +246,14 @@ event processing completes. You may however not call @ref glfwDestroyWindow from the close callback (or any other window related callback). @par Old syntax -@code{.c} +```c int GLFWCALL window_close_callback(void); -@endcode +``` @par New syntax -@code{.c} +```c void window_close_callback(GLFWwindow* window); -@endcode +``` @note GLFW never clears the close flag to `GLFW_FALSE`, meaning you can use it for other reasons to close the window as well, for example the user choosing @@ -287,14 +287,14 @@ produce characters with diacritical marks. Even the Swedish keyboard layout requires this for uncommon cases like ü. @par Old syntax -@code{.c} +```c void GLFWCALL character_callback(int character, int action); -@endcode +``` @par New syntax -@code{.c} +```c void character_callback(GLFWwindow* window, int character); -@endcode +``` ### Cursor position changes {#moving_cursorpos} @@ -322,14 +322,14 @@ two-dimensional floating point scroll offsets. This allows you to receive precise scroll data from for example modern touchpads. @par Old syntax -@code{.c} +```c void GLFWCALL mouse_wheel_callback(int position); -@endcode +``` @par New syntax -@code{.c} +```c void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); -@endcode +``` @par Removed functions `glfwGetMouseWheel` @@ -435,15 +435,15 @@ has been moved to GLFW 3, you can request that the GLFW header includes it by defining @ref GLFW_INCLUDE_GLU before the inclusion of the GLFW header. @par Old syntax -@code{.c} +```c #include -@endcode +``` @par New syntax -@code{.c} +```c #define GLFW_INCLUDE_GLU #include -@endcode +``` There are many libraries that offer replacements for the functionality offered by GLU. For the matrix helper functions, see math libraries like diff --git a/docs/news.md b/docs/news.md index 75928860..6cd54cef 100644 --- a/docs/news.md +++ b/docs/news.md @@ -161,11 +161,11 @@ 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} +```cmake set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE) add_subdirectory(path/to/glfw) -@endcode +``` #### macOS main menu now created at initialization {#initmenu_34} diff --git a/docs/quick.md b/docs/quick.md index 1ac22e51..f799fc59 100644 --- a/docs/quick.md +++ b/docs/quick.md @@ -19,9 +19,9 @@ behave differently in GLFW 3. In the source files of your application where you use GLFW, you need to include its header file. -@code{.c} +```c #include -@endcode +``` This header provides all the constants, types and function prototypes of the GLFW API. @@ -36,21 +36,21 @@ 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{.c} +```c #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{.c} +```c #define GLFW_INCLUDE_NONE #include #include -@endcode +``` ### Initializing and terminating GLFW {#quick_init_term} @@ -59,21 +59,21 @@ Before you can use most GLFW functions, the library must be initialized. On successful initialization, `GLFW_TRUE` is returned. If an error occurred, `GLFW_FALSE` is returned. -@code{.c} +```c if (!glfwInit()) { // Initialization failed } -@endcode +``` Note that `GLFW_TRUE` and `GLFW_FALSE` are and will always be one and zero. When you are done using GLFW, typically just before the application exits, you need to terminate GLFW. -@code{.c} +```c glfwTerminate(); -@endcode +``` This destroys any remaining windows and releases any other resources allocated by GLFW. After this call, you must initialize GLFW again before using any GLFW @@ -90,21 +90,21 @@ In case a GLFW function fails, an error is reported to the GLFW error callback. You can receive these reports with an error callback. This function must have the signature below but may do anything permitted in other callbacks. -@code{.c} +```c void error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); } -@endcode +``` Callback functions must be set, so GLFW knows to call them. The function to set the error callback is one of the few GLFW functions that may be called before initialization, which lets you be notified of errors both during and after initialization. -@code{.c} +```c glfwSetErrorCallback(error_callback); -@endcode +``` ### Creating a window and context {#quick_create_window} @@ -113,13 +113,13 @@ The window and its OpenGL context are created with a single call to @ref glfwCreateWindow, which returns a handle to the created combined window and context object -@code{.c} +```c GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); if (!window) { // Window or OpenGL context creation failed } -@endcode +``` This creates a 640 by 480 windowed mode window with an OpenGL context. If window or OpenGL context creation fails, `NULL` will be returned. You should @@ -136,7 +136,7 @@ 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{.c} +```c glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); @@ -145,13 +145,13 @@ if (!window) { // Window or context creation failed } -@endcode +``` When a window and context is no longer needed, destroy it. -@code{.c} +```c glfwDestroyWindow(window); -@endcode +``` Once this function is called, no more events will be delivered for that window and its handle becomes invalid. @@ -161,9 +161,9 @@ and its handle becomes invalid. Before you can use the OpenGL API, you must have a current OpenGL context. -@code{.c} +```c glfwMakeContextCurrent(window); -@endcode +``` The context will remain current until you make another context current or until the window owning the current context is destroyed. @@ -174,9 +174,9 @@ a current context to load from. This example uses [glad](https://github.com/Dav1dde/glad), but the same rule applies to all such libraries. -@code{.c} +```c gladLoadGL(glfwGetProcAddress); -@endcode +``` ### Checking the window close flag {#quick_window_close} @@ -189,12 +189,12 @@ Note that __the window isn't actually closed__, so you are expected to monitor this flag and either destroy the window or give some kind of feedback to the user. -@code{.c} +```c while (!glfwWindowShouldClose(window)) { // Keep running } -@endcode +``` You can be notified when the user is attempting to close the window by setting a close callback with @ref glfwSetWindowCloseCallback. The callback will be @@ -211,19 +211,19 @@ Each window has a large number of callbacks that can be set to receive all the various kinds of events. To receive key press and release events, create a key callback function. -@code{.c} +```c static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) glfwSetWindowShouldClose(window, GLFW_TRUE); } -@endcode +``` The key callback, like other window related callbacks, are set per-window. -@code{.c} +```c glfwSetKeyCallback(window, key_callback); -@endcode +``` In order for event callbacks to be called when events occur, you need to process events as described below. @@ -235,11 +235,11 @@ Once you have a current OpenGL context, you can use OpenGL normally. In this tutorial, a multicolored rotating triangle will be rendered. The framebuffer size needs to be retrieved for `glViewport`. -@code{.c} +```c int width, height; glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); -@endcode +``` You can also set a framebuffer size callback using @ref glfwSetFramebufferSizeCallback and be notified when the size changes. @@ -263,9 +263,9 @@ returns the number of seconds since initialization. The time source used is the most accurate on each platform and generally has micro- or nanosecond resolution. -@code{.c} +```c double time = glfwGetTime(); -@endcode +``` ### Swapping buffers {#quick_swap_buffers} @@ -277,9 +277,9 @@ the one being displayed and the back buffer the one you render to. When the entire frame has been rendered, the buffers need to be swapped with one another, so the back buffer becomes the front buffer and vice versa. -@code{.c} +```c glfwSwapBuffers(window); -@endcode +``` The swap interval indicates how many frames to wait until swapping the buffers, commonly known as _vsync_. By default, the swap interval is zero, meaning @@ -294,9 +294,9 @@ For these reasons, applications will typically want to set the swap interval to one. It can be set to higher values, but this is usually not recommended, because of the input latency it leads to. -@code{.c} +```c glfwSwapInterval(1); -@endcode +``` This function acts on the current context and will fail unless a context is current. @@ -313,9 +313,9 @@ There are two methods for processing pending events; polling and waiting. This example will use event polling, which processes only those events that have already been received and then returns immediately. -@code{.c} +```c glfwPollEvents(); -@endcode +``` This is the best choice when rendering continually, like most games do. If instead you only need to update your rendering once you have received new input, diff --git a/docs/vulkan.md b/docs/vulkan.md index b96e4c61..5eb2771e 100644 --- a/docs/vulkan.md +++ b/docs/vulkan.md @@ -43,9 +43,9 @@ you will need to direct GLFW to it. Pass your version of `vkGetInstanceProcAddr glfwInitVulkanLoader before initializing GLFW and it will use that function for all Vulkan entry point retrieval. This prevents GLFW from dynamically loading the Vulkan loader. -@code{.c} +```c glfwInitVulkanLoader(vkGetInstanceProcAddr); -@endcode +``` @macos To make your application be redistributable you will need to set up the application bundle according to the LunarG SDK documentation. This is explained in more detail in the @@ -57,18 +57,18 @@ bundle according to the LunarG SDK documentation. This is explained in more det To have GLFW include the Vulkan header, define @ref GLFW_INCLUDE_VULKAN before including the GLFW header. -@code{.c} +```c #define GLFW_INCLUDE_VULKAN #include -@endcode +``` If you instead want to include the Vulkan header from a custom location or use your own custom Vulkan header then do this before the GLFW header. -@code{.c} +```c #include #include -@endcode +``` Unless a Vulkan header is included, either by the GLFW header or above it, the following GLFW functions will not be declared, as depend on Vulkan types. @@ -92,12 +92,12 @@ If you are loading the Vulkan loader dynamically instead of linking directly against it, you can check for the availability of a loader and ICD with @ref glfwVulkanSupported. -@code{.c} +```c if (glfwVulkanSupported()) { // Vulkan is available, at least for compute } -@endcode +``` This function returns `GLFW_TRUE` if the Vulkan loader and any minimally functional ICD was found. @@ -112,18 +112,18 @@ To load any Vulkan core or extension function from the found loader, call @ref glfwGetInstanceProcAddress. To load functions needed for instance creation, pass `NULL` as the instance. -@code{.c} +```c PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance) glfwGetInstanceProcAddress(NULL, "vkCreateInstance"); -@endcode +``` Once you have created an instance, you can load from it all other Vulkan core functions and functions from any instance extensions you enabled. -@code{.c} +```c PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice) glfwGetInstanceProcAddress(instance, "vkCreateDevice"); -@endcode +``` This function in turn calls `vkGetInstanceProcAddr`. If that fails, the function falls back to a platform-specific query of the Vulkan loader (i.e. @@ -135,10 +135,10 @@ Vulkan also provides `vkGetDeviceProcAddr` for loading device-specific versions of Vulkan function. This function can be retrieved from an instance with @ref glfwGetInstanceProcAddress. -@code{.c} +```c PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) glfwGetInstanceProcAddress(instance, "vkGetDeviceProcAddr"); -@endcode +``` Device-specific functions may execute a little faster, due to not having to dispatch internally based on the device passed to them. For more information @@ -154,10 +154,10 @@ GLFW requires to create Vulkan surfaces. To query the instance extensions required, call @ref glfwGetRequiredInstanceExtensions. -@code{.c} +```c uint32_t count; const char** extensions = glfwGetRequiredInstanceExtensions(&count); -@endcode +``` These extensions must all be enabled when creating instances that are going to be passed to @ref glfwGetPhysicalDevicePresentationSupport and @ref @@ -172,14 +172,14 @@ If successful the returned array will always include `VK_KHR_surface`, so if you don't require any additional extensions you can pass this list directly to the `VkInstanceCreateInfo` struct. -@code{.c} +```c VkInstanceCreateInfo ici; memset(&ici, 0, sizeof(ici)); ici.enabledExtensionCount = count; ici.ppEnabledExtensionNames = extensions; ... -@endcode +``` Additional extensions may be required by future versions of GLFW. You should check whether any extensions you wish to enable are already in the returned @@ -201,12 +201,12 @@ To check whether a specific queue family of a physical device supports image presentation without first having to create a window and surface, call @ref glfwGetPhysicalDevicePresentationSupport. -@code{.c} +```c if (glfwGetPhysicalDevicePresentationSupport(instance, physical_device, queue_family_index)) { // Queue family supports image presentation } -@endcode +``` The `VK_KHR_surface` extension additionally provides the `vkGetPhysicalDeviceSurfaceSupportKHR` function, which performs the same test on @@ -219,10 +219,10 @@ Unless you will be using OpenGL or OpenGL ES with the same window as Vulkan, there is no need to create a context. You can disable context creation with the [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint. -@code{.c} +```c glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL); -@endcode +``` See @ref context_less for more information. @@ -232,14 +232,14 @@ See @ref context_less for more information. You can create a Vulkan surface (as defined by the `VK_KHR_surface` extension) for a GLFW window with @ref glfwCreateWindowSurface. -@code{.c} +```c VkSurfaceKHR surface; VkResult err = glfwCreateWindowSurface(instance, window, NULL, &surface); if (err) { // Window surface creation failed } -@endcode +``` If an OpenGL or OpenGL ES context was created on the window, the context has ownership of the presentation on the window and a Vulkan surface cannot be diff --git a/docs/window.md b/docs/window.md index e3c8f7a9..437c1f7e 100644 --- a/docs/window.md +++ b/docs/window.md @@ -30,9 +30,9 @@ A window and its OpenGL or OpenGL ES context are created with @ref glfwCreateWindow, which returns a handle to the created window object. For example, this creates a 640 by 480 windowed mode window: -@code{.c} +```c GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); -@endcode +``` If window creation fails, `NULL` will be returned, so it is necessary to check the return value. @@ -48,9 +48,9 @@ To create a full screen window, you need to specify which monitor the window should use. In most cases, the user's primary monitor is a good choice. For more information about retrieving monitors, see @ref monitor_monitors. -@code{.c} +```c GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL); -@endcode +``` Full screen windows cover the entire display area of a monitor, have no border or decorations. @@ -99,7 +99,7 @@ switching much smoother. This is sometimes called _windowed full screen_ or _borderless full screen_ window and counts as a full screen window. To create such a window, request the current video mode. -@code{.c} +```c const GLFWvidmode* mode = glfwGetVideoMode(monitor); glfwWindowHint(GLFW_RED_BITS, mode->redBits); @@ -108,15 +108,15 @@ glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate); GLFWwindow* window = glfwCreateWindow(mode->width, mode->height, "My Title", monitor, NULL); -@endcode +``` This also works for windowed mode windows that are made full screen. -@code{.c} +```c const GLFWvidmode* mode = glfwGetVideoMode(monitor); glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); -@endcode +``` Note that @ref glfwGetVideoMode returns the _current_ video mode of a monitor, so if you already have a full screen window on that monitor that you want to @@ -127,9 +127,9 @@ make windowed full screen, you need to have saved the desktop resolution before. When a window is no longer needed, destroy it with @ref glfwDestroyWindow. -@code{.c} +```c glfwDestroyWindow(window); -@endcode +``` Window destruction always succeeds. Before the actual destruction, all callbacks are removed so no further events will be delivered for the window. @@ -596,7 +596,7 @@ The current state of the close flag is returned by @ref glfwWindowShouldClose and can be set or cleared directly with @ref glfwSetWindowShouldClose. A common pattern is to use the close flag as a main loop condition. -@code{.c} +```c while (!glfwWindowShouldClose(window)) { render(window); @@ -604,26 +604,26 @@ while (!glfwWindowShouldClose(window)) glfwSwapBuffers(window); glfwPollEvents(); } -@endcode +``` If you wish to be notified when the user attempts to close a window, set a close callback. -@code{.c} +```c glfwSetWindowCloseCallback(window, window_close_callback); -@endcode +``` The callback function is called directly _after_ the close flag has been set. It can be used for example to filter close requests and clear the close flag again unless certain conditions are met. -@code{.c} +```c void window_close_callback(GLFWwindow* window) { if (!time_to_close) glfwSetWindowShouldClose(window, GLFW_FALSE); } -@endcode +``` ### Window size {#window_size} @@ -633,9 +633,9 @@ mode windows, this sets the size, in [screen coordinates](@ref coordinate_systems) of the _content area_ or _content area_ of the window. The window system may impose limits on window size. -@code{.c} +```c glfwSetWindowSize(window, 640, 480); -@endcode +``` For full screen windows, the specified size becomes the new resolution of the window's desired video mode. The video mode most closely matching the new @@ -645,26 +645,26 @@ resolution of the set video mode. If you wish to be notified when a window is resized, whether by the user, the system or your own code, set a size callback. -@code{.c} +```c glfwSetWindowSizeCallback(window, window_size_callback); -@endcode +``` The callback function receives the new size, in screen coordinates, of the content area of the window when the window is resized. -@code{.c} +```c void window_size_callback(GLFWwindow* window, int width, int height) { } -@endcode +``` There is also @ref glfwGetWindowSize for directly retrieving the current size of a window. -@code{.c} +```c int width, height; glfwGetWindowSize(window, &width, &height); -@endcode +``` @note Do not pass the window size to `glViewport` or other pixel-based OpenGL calls. The window size is in screen coordinates, not pixels. Use the @@ -675,10 +675,10 @@ The above functions work with the size of the content area, but decorated windows typically have title bars and window frames around this rectangle. You can retrieve the extents of these with @ref glfwGetWindowFrameSize. -@code{.c} +```c int left, top, right, bottom; glfwGetWindowFrameSize(window, &left, &top, &right, &bottom); -@endcode +``` The returned values are the distances, in screen coordinates, from the edges of the content area to the corresponding edges of the full window. As they are @@ -696,28 +696,28 @@ pixels, of the framebuffer of a window. If you wish to be notified when the framebuffer of a window is resized, whether by the user or the system, set a size callback. -@code{.c} +```c glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); -@endcode +``` The callback function receives the new size of the framebuffer when it is resized, which can for example be used to update the OpenGL viewport. -@code{.c} +```c void framebuffer_size_callback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); } -@endcode +``` There is also @ref glfwGetFramebufferSize for directly retrieving the current size of the framebuffer of a window. -@code{.c} +```c int width, height; glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); -@endcode +``` The size of a framebuffer may change independently of the size of a window, for example if the window is dragged between a regular monitor and a high-DPI one. @@ -728,10 +728,10 @@ example if the window is dragged between a regular monitor and a high-DPI one. The content scale for a window can be retrieved with @ref glfwGetWindowContentScale. -@code{.c} +```c float xscale, yscale; glfwGetWindowContentScale(window, &xscale, &yscale); -@endcode +``` The content scale is the ratio between the current DPI and the platform's default DPI. This is especially important for text and any UI elements. If the @@ -748,18 +748,18 @@ If you wish to be notified when the content scale of a window changes, whether because of a system setting change or because it was moved to a monitor with a different scale, set a content scale callback. -@code{.c} +```c glfwSetWindowContentScaleCallback(window, window_content_scale_callback); -@endcode +``` The callback function receives the new content scale of the window. -@code{.c} +```c void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale) { set_interface_scale(xscale, yscale); } -@endcode +``` On platforms where pixels and screen coordinates always map 1:1, the window will need to be resized to appear the same size when it is moved to a monitor @@ -775,16 +775,16 @@ be enforced with @ref glfwSetWindowSizeLimits. The user may resize the window to any size and aspect ratio within the specified limits, unless the aspect ratio is also set. -@code{.c} +```c glfwSetWindowSizeLimits(window, 200, 200, 400, 400); -@endcode +``` To specify only a minimum size or only a maximum one, set the other pair to `GLFW_DONT_CARE`. -@code{.c} +```c glfwSetWindowSizeLimits(window, 640, 480, GLFW_DONT_CARE, GLFW_DONT_CARE); -@endcode +``` To disable size limits for a window, set them all to `GLFW_DONT_CARE`. @@ -793,19 +793,19 @@ with @ref glfwSetWindowAspectRatio. The user may resize the window freely unless size limits are also set, but the size will be constrained to maintain the aspect ratio. -@code{.c} +```c glfwSetWindowAspectRatio(window, 16, 9); -@endcode +``` The aspect ratio is specified as a numerator and denominator, corresponding to the width and height, respectively. If you want a window to maintain its current aspect ratio, use its current size as the ratio. -@code{.c} +```c int width, height; glfwGetWindowSize(window, &width, &height); glfwSetWindowAspectRatio(window, width, height); -@endcode +``` To disable the aspect ratio limit for a window, set both terms to `GLFW_DONT_CARE`. @@ -822,10 +822,10 @@ This is most often the right choice. If you need to create a window at a specific position, you can set the desired position with the @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints. -@code{.c} +```c glfwWindowHint(GLFW_POSITION_X, 70); glfwWindowHint(GLFW_POSITION_Y, 83); -@endcode +``` To restore the previous behavior, set these hints to `GLFW_ANY_POSITION`. @@ -834,33 +834,33 @@ glfwSetWindowPos. This moves the window so that the upper-left corner of its content area has the specified [screen coordinates](@ref coordinate_systems). The window system may put limitations on window placement. -@code{.c} +```c glfwSetWindowPos(window, 100, 100); -@endcode +``` If you wish to be notified when a window is moved, whether by the user, the system or your own code, set a position callback. -@code{.c} +```c glfwSetWindowPosCallback(window, window_pos_callback); -@endcode +``` The callback function receives the new position, in screen coordinates, of the upper-left corner of the content area when the window is moved. -@code{.c} +```c void window_pos_callback(GLFWwindow* window, int xpos, int ypos) { } -@endcode +``` There is also @ref glfwGetWindowPos for directly retrieving the current position of the content area of the window. -@code{.c} +```c int xpos, ypos; glfwGetWindowPos(window, &xpos, &ypos); -@endcode +``` ### Window title {#window_title} @@ -869,9 +869,9 @@ All GLFW windows have a title, although undecorated or full screen windows may not display it or only display it in a task bar or similar interface. You can set a UTF-8 encoded window title with @ref glfwSetWindowTitle. -@code{.c} +```c glfwSetWindowTitle(window, "My Window"); -@endcode +``` The specified string is copied before the function returns, so there is no need to keep it around. @@ -879,15 +879,15 @@ to keep it around. As long as your source file is encoded as UTF-8, you can use any Unicode characters directly in the source. -@code{.c} +```c glfwSetWindowTitle(window, "ラストエグザイル"); -@endcode +``` If you are using C++11 or C11, you can use a UTF-8 string literal. -@code{.c} +```c glfwSetWindowTitle(window, u8"This is always a UTF-8 string"); -@endcode +``` ### Window icon {#window_icon} @@ -895,13 +895,13 @@ glfwSetWindowTitle(window, u8"This is always a UTF-8 string"); Decorated windows have icons on some platforms. You can set this icon by specifying a list of candidate images with @ref glfwSetWindowIcon. -@code{.c} +```c GLFWimage images[2]; images[0] = load_icon("my_icon.png"); images[1] = load_icon("my_icon_small.png"); glfwSetWindowIcon(window, 2, images); -@endcode +``` The image data is 32-bit, little-endian, non-premultiplied RGBA, i.e. eight bits per channel with the red channel first. The pixels are arranged canonically as @@ -909,9 +909,9 @@ sequential rows, starting from the top-left corner. To revert to the default window icon, pass in an empty image array. -@code{.c} +```c glfwSetWindowIcon(window, 0, NULL); -@endcode +``` ### Window monitor {#window_monitor} @@ -919,9 +919,9 @@ glfwSetWindowIcon(window, 0, NULL); Full screen windows are associated with a specific monitor. You can get the handle for this monitor with @ref glfwGetWindowMonitor. -@code{.c} +```c GLFWmonitor* monitor = glfwGetWindowMonitor(window); -@endcode +``` This monitor handle is one of those returned by @ref glfwGetMonitors. @@ -933,18 +933,18 @@ with @ref glfwSetWindowMonitor. When making a window full screen on the same or on a different monitor, specify the desired monitor, resolution and refresh rate. The position arguments are ignored. -@code{.c} +```c const GLFWvidmode* mode = glfwGetVideoMode(monitor); glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); -@endcode +``` When making the window windowed, specify the desired position and size. The refresh rate argument is ignored. -@code{.c} +```c glfwSetWindowMonitor(window, NULL, xpos, ypos, width, height, 0); -@endcode +``` This restores any previous window settings such as whether it is decorated, floating, resizable, has size or aspect ratio limits, etc.. To restore a window @@ -956,9 +956,9 @@ before making it full screen and then pass them in as above. Windows can be iconified (i.e. minimized) with @ref glfwIconifyWindow. -@code{.c} +```c glfwIconifyWindow(window); -@endcode +``` When a full screen window is iconified, the original video mode of its monitor is restored until the user or application restores the window. @@ -966,9 +966,9 @@ is restored until the user or application restores the window. Iconified windows can be restored with @ref glfwRestoreWindow. This function also restores windows from maximization. -@code{.c} +```c glfwRestoreWindow(window); -@endcode +``` When a full screen window is restored, the desired video mode is restored to its monitor as well. @@ -976,13 +976,13 @@ monitor as well. If you wish to be notified when a window is iconified or restored, whether by the user, system or your own code, set an iconify callback. -@code{.c} +```c glfwSetWindowIconifyCallback(window, window_iconify_callback); -@endcode +``` The callback function receives changes in the iconification state of the window. -@code{.c} +```c void window_iconify_callback(GLFWwindow* window, int iconified) { if (iconified) @@ -994,22 +994,22 @@ void window_iconify_callback(GLFWwindow* window, int iconified) // The window was restored } } -@endcode +``` You can also get the current iconification state with @ref glfwGetWindowAttrib. -@code{.c} +```c int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); -@endcode +``` ### Window maximization {#window_maximize} Windows can be maximized (i.e. zoomed) with @ref glfwMaximizeWindow. -@code{.c} +```c glfwMaximizeWindow(window); -@endcode +``` Full screen windows cannot be maximized and passing a full screen window to this function does nothing. @@ -1017,20 +1017,20 @@ function does nothing. Maximized windows can be restored with @ref glfwRestoreWindow. This function also restores windows from iconification. -@code{.c} +```c glfwRestoreWindow(window); -@endcode +``` If you wish to be notified when a window is maximized or restored, whether by the user, system or your own code, set a maximize callback. -@code{.c} +```c glfwSetWindowMaximizeCallback(window, window_maximize_callback); -@endcode +``` The callback function receives changes in the maximization state of the window. -@code{.c} +```c void window_maximize_callback(GLFWwindow* window, int maximized) { if (maximized) @@ -1042,30 +1042,30 @@ void window_maximize_callback(GLFWwindow* window, int maximized) // The window was restored } } -@endcode +``` You can also get the current maximization state with @ref glfwGetWindowAttrib. -@code{.c} +```c int maximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED); -@endcode +``` By default, newly created windows are not maximized. You can change this behavior by setting the [GLFW_MAXIMIZED](@ref GLFW_MAXIMIZED_hint) window hint before creating the window. -@code{.c} +```c glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE); -@endcode +``` ### Window visibility {#window_hide} Windowed mode windows can be hidden with @ref glfwHideWindow. -@code{.c} +```c glfwHideWindow(window); -@endcode +``` This makes the window completely invisible to the user, including removing it from the task bar, dock or window list. Full screen windows cannot be hidden @@ -1073,9 +1073,9 @@ and calling @ref glfwHideWindow on a full screen window does nothing. Hidden windows can be shown with @ref glfwShowWindow. -@code{.c} +```c glfwShowWindow(window); -@endcode +``` By default, this function will also set the input focus to that window. Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint to change @@ -1084,17 +1084,17 @@ existing window with @ref glfwSetWindowAttrib. You can also get the current visibility state with @ref glfwGetWindowAttrib. -@code{.c} +```c int visible = glfwGetWindowAttrib(window, GLFW_VISIBLE); -@endcode +``` By default, newly created windows are visible. You can change this behavior by setting the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window hint before creating the window. -@code{.c} +```c glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); -@endcode +``` Windows created hidden are completely invisible to the user until shown. This can be useful if you need to set up your window further before showing it, for @@ -1106,9 +1106,9 @@ example moving it to a specific location. Windows can be given input focus and brought to the front with @ref glfwFocusWindow. -@code{.c} +```c glfwFocusWindow(window); -@endcode +``` Keep in mind that it can be very disruptive to the user when a window is forced to the top. For a less disruptive way of getting the user's attention, see @@ -1117,13 +1117,13 @@ to the top. For a less disruptive way of getting the user's attention, see If you wish to be notified when a window gains or loses input focus, whether by the user, system or your own code, set a focus callback. -@code{.c} +```c glfwSetWindowFocusCallback(window, window_focus_callback); -@endcode +``` The callback function receives changes in the input focus state of the window. -@code{.c} +```c void window_focus_callback(GLFWwindow* window, int focused) { if (focused) @@ -1135,21 +1135,21 @@ void window_focus_callback(GLFWwindow* window, int focused) // The window lost input focus } } -@endcode +``` You can also get the current input focus state with @ref glfwGetWindowAttrib. -@code{.c} +```c int focused = glfwGetWindowAttrib(window, GLFW_FOCUSED); -@endcode +``` By default, newly created windows are given input focus. You can change this behavior by setting the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) window hint before creating the window. -@code{.c} +```c glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE); -@endcode +``` ### Window attention request {#window_attention} @@ -1157,9 +1157,9 @@ glfwWindowHint(GLFW_FOCUSED, GLFW_FALSE); If you wish to notify the user of an event without interrupting, you can request attention with @ref glfwRequestWindowAttention. -@code{.c} +```c glfwRequestWindowAttention(window); -@endcode +``` The system will highlight the specified window, or on platforms where this is not supported, the application as a whole. Once the user has given it @@ -1171,20 +1171,20 @@ attention, the system will automatically end the request. If you wish to be notified when the contents of a window is damaged and needs to be refreshed, set a window refresh callback. -@code{.c} +```c glfwSetWindowRefreshCallback(m_handle, window_refresh_callback); -@endcode +``` The callback function is called when the contents of the window needs to be refreshed. -@code{.c} +```c void window_refresh_callback(GLFWwindow* window) { draw_editor_ui(window); glfwSwapBuffers(window); } -@endcode +``` @note On compositing window systems such as Aero, Compiz or Aqua, where the window contents are saved off-screen, this callback might only be called when @@ -1205,9 +1205,9 @@ Window framebuffers can be made transparent on a per-pixel per-frame basis with the [GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) window hint. -@code{.c} +```c glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, GLFW_TRUE); -@endcode +``` If supported by the system, the window content area will be composited with the background using the framebuffer per-pixel alpha channel. This requires desktop @@ -1218,21 +1218,21 @@ with the [GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib) window attribute. -@code{.c} +```c if (glfwGetWindowAttrib(window, GLFW_TRANSPARENT_FRAMEBUFFER)) { // window framebuffer is currently transparent } -@endcode +``` GLFW comes with an example that enabled framebuffer transparency called `gears`. The opacity of the whole window, including any decorations, can be set with @ref glfwSetWindowOpacity. -@code{.c} +```c glfwSetWindowOpacity(window, 0.5f); -@endcode +``` The opacity (or alpha) value is a positive finite number between zero and one, where 0 (zero) is fully transparent and 1 (one) is fully opaque. The initial @@ -1240,9 +1240,9 @@ opacity value for newly created windows is 1. The current opacity of a window can be queried with @ref glfwGetWindowOpacity. -@code{.c} +```c float opacity = glfwGetWindowOpacity(window); -@endcode +``` If the system does not support whole window transparency, this function always returns one. @@ -1263,12 +1263,12 @@ interaction, (e.g. whether it has input focus), while others reflect inherent properties of the window (e.g. what kind of border it has). Some are related to the window and others to its OpenGL or OpenGL ES context. -@code{.c} +```c if (glfwGetWindowAttrib(window, GLFW_FOCUSED)) { // window has input focus } -@endcode +``` The [GLFW_DECORATED](@ref GLFW_DECORATED_attrib), [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib), @@ -1277,9 +1277,9 @@ The [GLFW_DECORATED](@ref GLFW_DECORATED_attrib), [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib) window attributes can be changed with @ref glfwSetWindowAttrib. -@code{.c} +```c glfwSetWindowAttrib(window, GLFW_RESIZABLE, GLFW_FALSE); -@endcode +``` @@ -1463,18 +1463,18 @@ When the entire frame has been rendered, it is time to swap the back and the front buffers in order to display what has been rendered and begin rendering a new frame. This is done with @ref glfwSwapBuffers. -@code{.c} +```c glfwSwapBuffers(window); -@endcode +``` 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 should wait from the time @ref glfwSwapBuffers was called before swapping the buffers: -@code{.c} +```c glfwSwapInterval(1); -@endcode +``` If the interval is zero, the swap will take place immediately when @ref glfwSwapBuffers is called without waiting for a refresh. Otherwise at least From 973a3c0b31558b53373816958a9ee4b4c1687f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Feb 2024 21:11:29 +0100 Subject: [PATCH 081/137] Fix Markdown syntax for link --- docs/moving.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/moving.md b/docs/moving.md index ace4ebdf..44b79479 100644 --- a/docs/moving.md +++ b/docs/moving.md @@ -85,7 +85,7 @@ platform-independent, as both OpenGL and stdio are available wherever GLFW is. ### Removal of GLFWCALL macro {#moving_stdcall} The `GLFWCALL` macro, which made callback functions use -[__stdcall](https://msdn.microsoft.com/en-us/library/zxk0tw93.aspx) on Windows, +[\_\_stdcall](https://msdn.microsoft.com/en-us/library/zxk0tw93.aspx) on Windows, has been removed. GLFW is written in C, not Pascal. Removing this macro means there's one less thing for application programmers to remember, i.e. the requirement to mark all callback functions with `GLFWCALL`. It also simplifies From 244852a93a96c4d10e59b2a4a31136d909400cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Feb 2024 22:17:58 +0100 Subject: [PATCH 082/137] Convert Doxygen paragraphs to Markdown --- docs/moving.md | 68 +++++++++++++++++++++++++------------------------- docs/window.md | 1 - 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/docs/moving.md b/docs/moving.md index 44b79479..2f992dba 100644 --- a/docs/moving.md +++ b/docs/moving.md @@ -19,12 +19,12 @@ avoid collisions with the headers of other major versions. Similarly, the GLFW Unix-like systems, where it uses the [soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`. -@par Old syntax +__Old syntax__ ```c #include ``` -@par New syntax +__New syntax__ ```c #include ``` @@ -53,14 +53,14 @@ However, GLFW 3 has better support for _use from multiple threads_ than GLFW thread at a time, and the documentation explicitly states which functions may be used from any thread and which must only be used from the main thread. -@par Removed functions -`glfwSleep`, `glfwCreateThread`, `glfwDestroyThread`, `glfwWaitThread`, -`glfwGetThreadID`, `glfwCreateMutex`, `glfwDestroyMutex`, `glfwLockMutex`, -`glfwUnlockMutex`, `glfwCreateCond`, `glfwDestroyCond`, `glfwWaitCond`, -`glfwSignalCond`, `glfwBroadcastCond` and `glfwGetNumberOfProcessors`. +__Removed functions__ +> `glfwSleep`, `glfwCreateThread`, `glfwDestroyThread`, `glfwWaitThread`, +> `glfwGetThreadID`, `glfwCreateMutex`, `glfwDestroyMutex`, `glfwLockMutex`, +> `glfwUnlockMutex`, `glfwCreateCond`, `glfwDestroyCond`, `glfwWaitCond`, +> `glfwSignalCond`, `glfwBroadcastCond` and `glfwGetNumberOfProcessors`. -@par Removed types -`GLFWthreadfun` +__Removed types__ +> `GLFWthreadfun` ### Removal of image and texture loading {#moving_image} @@ -77,9 +77,9 @@ As there already are libraries doing this, it is unnecessary both to duplicate the work and to tie the duplicate to GLFW. The resulting library would also be platform-independent, as both OpenGL and stdio are available wherever GLFW is. -@par Removed functions -`glfwReadImage`, `glfwReadMemoryImage`, `glfwFreeImage`, `glfwLoadTexture2D`, -`glfwLoadMemoryTexture2D` and `glfwLoadTextureImage2D`. +__Removed functions__ +> `glfwReadImage`, `glfwReadMemoryImage`, `glfwFreeImage`, `glfwLoadTexture2D`, +> `glfwLoadMemoryTexture2D` and `glfwLoadTextureImage2D`. ### Removal of GLFWCALL macro {#moving_stdcall} @@ -92,12 +92,12 @@ requirement to mark all callback functions with `GLFWCALL`. It also simplifies the creation of DLLs and DLL link libraries, as there's no need to explicitly disable `@n` entry point suffixes. -@par Old syntax +__Old syntax__ ```c void GLFWCALL callback_function(...); ``` -@par New syntax +__New syntax__ ```c void callback_function(...); ``` @@ -111,12 +111,12 @@ a newly created window is returned by @ref glfwCreateWindow (formerly `glfwOpenWindow`). Window handles are pointers to the [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow. -@par Old syntax +__Old syntax__ ```c glfwSetWindowTitle("New Window Title"); ``` -@par New syntax +__New syntax__ ```c glfwSetWindowTitle(window, "New Window Title"); ``` @@ -131,12 +131,12 @@ GLFW 2 would have selected, but there are many other [monitor functions](@ref monitor_guide). Monitor handles are pointers to the [opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor. -@par Old basic full screen +__Old basic full screen__ ```c glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN); ``` -@par New basic full screen +__New basic full screen__ ```c window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL); ``` @@ -153,7 +153,7 @@ you need to call @ref glfwPollEvents or @ref glfwWaitEvents yourself. Unlike buffer swap, which acts on a single window, the event processing functions act on all windows at once. -@par Old basic main loop +__Old basic main loop__ ```c while (...) { @@ -163,7 +163,7 @@ while (...) } ``` -@par New basic main loop +__New basic main loop__ ```c while (...) { @@ -195,13 +195,13 @@ been added. You can retrieve the size of the framebuffer of a window with @ref glfwGetFramebufferSize function. A framebuffer size callback has also been added, which can be set with @ref glfwSetFramebufferSizeCallback. -@par Old basic viewport setup +__Old basic viewport setup__ ```c glfwGetWindowSize(&width, &height); glViewport(0, 0, width, height); ``` -@par New basic viewport setup +__New basic viewport setup__ ```c glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); @@ -224,7 +224,7 @@ the window, take some other action or ignore the request. You can query the close flag at any time with @ref glfwWindowShouldClose and set it at any time with @ref glfwSetWindowShouldClose. -@par Old basic main loop +__Old basic main loop__ ```c while (glfwGetWindowParam(GLFW_OPENED)) { @@ -232,7 +232,7 @@ while (glfwGetWindowParam(GLFW_OPENED)) } ``` -@par New basic main loop +__New basic main loop__ ```c while (!glfwWindowShouldClose(window)) { @@ -245,12 +245,12 @@ close flag has been set, so it can optionally override its value, before event processing completes. You may however not call @ref glfwDestroyWindow from the close callback (or any other window related callback). -@par Old syntax +__Old syntax__ ```c int GLFWCALL window_close_callback(void); ``` -@par New syntax +__New syntax__ ```c void window_close_callback(GLFWwindow* window); ``` @@ -286,12 +286,12 @@ English by a Swede. However, many keyboard layouts require more than one key to produce characters with diacritical marks. Even the Swedish keyboard layout requires this for uncommon cases like ü. -@par Old syntax +__Old syntax__ ```c void GLFWCALL character_callback(int character, int action); ``` -@par New syntax +__New syntax__ ```c void character_callback(GLFWwindow* window, int character); ``` @@ -321,18 +321,18 @@ replaced by a [scroll callback](@ref GLFWscrollfun) that receives two-dimensional floating point scroll offsets. This allows you to receive precise scroll data from for example modern touchpads. -@par Old syntax +__Old syntax__ ```c void GLFWCALL mouse_wheel_callback(int position); ``` -@par New syntax +__New syntax__ ```c void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); ``` -@par Removed functions -`glfwGetMouseWheel` +__Removed functions__ +> `glfwGetMouseWheel` ### Key repeat action {#moving_repeat} @@ -434,12 +434,12 @@ projects should not use GLU__, but if you need it for legacy code that has been moved to GLFW 3, you can request that the GLFW header includes it by defining @ref GLFW_INCLUDE_GLU before the inclusion of the GLFW header. -@par Old syntax +__Old syntax__ ```c #include ``` -@par New syntax +__New syntax__ ```c #define GLFW_INCLUDE_GLU #include diff --git a/docs/window.md b/docs/window.md index 437c1f7e..dda6638b 100644 --- a/docs/window.md +++ b/docs/window.md @@ -1382,7 +1382,6 @@ OpenGL forward-compatible one, or `GLFW_FALSE` otherwise. __GLFW_CONTEXT_DEBUG__ is `GLFW_TRUE` if the window's context is in debug mode, or `GLFW_FALSE` otherwise. -@par This is the new name, introduced in GLFW 3.4. The older `GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility. From 532bd66e7fe9fc0606ee9a0c432b7e82b3b89beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 13 Feb 2024 22:42:49 +0100 Subject: [PATCH 083/137] Convert Doxygen tables of contents to Markdown --- docs/build.md | 2 +- docs/compat.md | 2 +- docs/compile.md | 2 +- docs/context.md | 2 +- docs/input.md | 2 +- docs/internal.md | 2 +- docs/intro.md | 2 +- docs/monitor.md | 2 +- docs/moving.md | 2 +- docs/news.md | 2 +- docs/quick.md | 2 +- docs/vulkan.md | 2 +- docs/window.md | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/build.md b/docs/build.md index 06085431..9566b152 100644 --- a/docs/build.md +++ b/docs/build.md @@ -1,6 +1,6 @@ # Building applications {#build_guide} -@tableofcontents +[TOC] This is about compiling and linking applications that use GLFW. For information on how to write such applications, start with the diff --git a/docs/compat.md b/docs/compat.md index 0d363a79..1c76a713 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -1,6 +1,6 @@ # Standards conformance {#compat_guide} -@tableofcontents +[TOC] This guide describes the various API extensions used by this version of GLFW. It lists what are essentially implementation details, but which are nonetheless diff --git a/docs/compile.md b/docs/compile.md index 70dba5ff..5703cf80 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -1,6 +1,6 @@ # Compiling GLFW {#compile_guide} -@tableofcontents +[TOC] This is about compiling the GLFW library itself. For information on how to build applications that use GLFW, see @ref build_guide. diff --git a/docs/context.md b/docs/context.md index 755addde..bf70553b 100644 --- a/docs/context.md +++ b/docs/context.md @@ -1,6 +1,6 @@ # Context guide {#context_guide} -@tableofcontents +[TOC] This guide introduces the OpenGL and OpenGL ES context related functions of GLFW. For details on a specific function in this category, see the @ref diff --git a/docs/input.md b/docs/input.md index c11e7c61..5915c227 100644 --- a/docs/input.md +++ b/docs/input.md @@ -1,6 +1,6 @@ # Input guide {#input_guide} -@tableofcontents +[TOC] This guide introduces the input related functions of GLFW. For details on a specific function in this category, see the @ref input. There are also guides diff --git a/docs/internal.md b/docs/internal.md index 46fc8bae..b658d77b 100644 --- a/docs/internal.md +++ b/docs/internal.md @@ -1,6 +1,6 @@ # Internal structure {#internals_guide} -@tableofcontents +[TOC] There are several interfaces inside GLFW. Each interface has its own area of responsibility and its own naming conventions. diff --git a/docs/intro.md b/docs/intro.md index aa3bed01..d30ab33c 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -1,6 +1,6 @@ # Introduction to the API {#intro_guide} -@tableofcontents +[TOC] This guide introduces the basic concepts of GLFW and describes initialization, error handling and API guarantees and limitations. For a broad but shallow diff --git a/docs/monitor.md b/docs/monitor.md index 27cf6793..d6d83cb3 100644 --- a/docs/monitor.md +++ b/docs/monitor.md @@ -1,6 +1,6 @@ # Monitor guide {#monitor_guide} -@tableofcontents +[TOC] This guide introduces the monitor related functions of GLFW. For details on a specific function in this category, see the @ref monitor. There are also diff --git a/docs/moving.md b/docs/moving.md index 2f992dba..d50b7ffe 100644 --- a/docs/moving.md +++ b/docs/moving.md @@ -1,6 +1,6 @@ # Moving from GLFW 2 to 3 {#moving_guide} -@tableofcontents +[TOC] This is a transition guide for moving from GLFW 2 to 3. It describes what has changed or been removed, but does _not_ include diff --git a/docs/news.md b/docs/news.md index 6cd54cef..7e9c4ed6 100644 --- a/docs/news.md +++ b/docs/news.md @@ -1,6 +1,6 @@ # Release notes {#news} -@tableofcontents +[TOC] ## Release notes for version 3.4 {#news_34} diff --git a/docs/quick.md b/docs/quick.md index f799fc59..f3498231 100644 --- a/docs/quick.md +++ b/docs/quick.md @@ -1,6 +1,6 @@ # Getting started {#quick_guide} -@tableofcontents +[TOC] 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 diff --git a/docs/vulkan.md b/docs/vulkan.md index 5eb2771e..cb67302f 100644 --- a/docs/vulkan.md +++ b/docs/vulkan.md @@ -1,6 +1,6 @@ # Vulkan guide {#vulkan_guide} -@tableofcontents +[TOC] This guide is intended to fill the gaps between the official [Vulkan resources](https://www.khronos.org/vulkan/) and the rest of the GLFW diff --git a/docs/window.md b/docs/window.md index dda6638b..8ab7051f 100644 --- a/docs/window.md +++ b/docs/window.md @@ -1,6 +1,6 @@ # Window guide {#window_guide} -@tableofcontents +[TOC] This guide introduces the window related functions of GLFW. For details on a specific function in this category, see the @ref window. There are also From 63397fb0d5d2d8f508669475fbb48602a1edff23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 14 Feb 2024 01:36:35 +0100 Subject: [PATCH 084/137] Convert some external links to reference links --- docs/build.md | 42 +++++++++------- docs/compat.md | 111 +++++++++++++++++++++++-------------------- docs/compile.md | 21 ++++---- docs/input.md | 11 +++-- docs/intro.md | 14 +++--- docs/moving.md | 71 +++++++++++++++------------ docs/news.md | 5 +- docs/quick.md | 5 +- docs/window.md | 15 +++--- include/GLFW/glfw3.h | 27 ++++++----- 10 files changed, 181 insertions(+), 141 deletions(-) diff --git a/docs/build.md b/docs/build.md index 9566b152..6a5b4a0f 100644 --- a/docs/build.md +++ b/docs/build.md @@ -41,12 +41,13 @@ In other words: - 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. 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. +If you are using an OpenGL extension loading library such as [glad][], the +extension loader header should 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. + +[glad]: https://github.com/Dav1dde/glad ```c #include @@ -80,8 +81,9 @@ 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/). +SDK, and most of them can be downloaded from the [Khronos Registry][registry]. + +[registry]: https://www.khronos.org/registry/ @anchor GLFW_INCLUDE_GLCOREARB __GLFW_INCLUDE_GLCOREARB__ makes the GLFW header include the modern @@ -153,9 +155,10 @@ hard-coded into your build environment. See the section for your development environment below. On Linux and other Unix-like operating systems, the list varies but can be retrieved in various ways as described below. -A good general introduction to linking is -[Beginner's Guide to Linkers](https://www.lurklurk.org/linkers/linkers.html) by -David Drysdale. +A good general introduction to linking is [Beginner's Guide to +Linkers][linker_guide] by David Drysdale. + +[linker_guide]: https://www.lurklurk.org/linkers/linkers.html ### With MinGW or Visual C++ on Windows {#build_link_win32} @@ -217,7 +220,9 @@ target_link_libraries(myapp OpenGL::GL) ``` 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. +[GLFW CMake Starter][cmake_starter] on GitHub. + +[cmake_starter]: https://github.com/juliettef/GLFW-CMake-starter ### With CMake and installed GLFW binaries {#build_link_cmake_package} @@ -261,12 +266,13 @@ target_link_libraries(myapp OpenGL::GL) ### With makefiles and pkg-config on Unix {#build_link_pkgconfig} -GLFW supports [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/), -and the `glfw3.pc` pkg-config file is generated when the GLFW library is built -and is installed along with it. A pkg-config file describes all necessary -compile-time and link-time flags and dependencies needed to use a library. When -they are updated or if they differ between systems, you will get the correct -ones automatically. +GLFW supports [pkg-config][], and the `glfw3.pc` pkg-config file is generated +when the GLFW library is built and is installed along with it. A pkg-config +file describes all necessary compile-time and link-time flags and dependencies +needed to use a library. When they are updated or if they differ between +systems, you will get the correct ones automatically. + +[pkg-config]: https://www.freedesktop.org/wiki/Software/pkg-config/ A typical compile and link command-line when using the static version of the GLFW library may look like this: diff --git a/docs/compat.md b/docs/compat.md index 1c76a713..202b8a4e 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -15,16 +15,16 @@ be considered a breaking API change. ## X11 extensions, protocols and IPC standards {#compat_x11} -As GLFW uses Xlib directly, without any intervening toolkit -library, it has sole responsibility for interacting well with the many and -varied window managers in use on Unix-like systems. In order for applications -and window managers to work well together, a number of standards and -conventions have been developed that regulate behavior outside the scope of the -X11 API; most importantly the -[Inter-Client Communication Conventions Manual](https://www.tronche.com/gui/x/icccm/) -(ICCCM) and -[Extended Window Manager Hints](https://standards.freedesktop.org/wm-spec/wm-spec-latest.html) -(EWMH) standards. +As GLFW uses Xlib directly, without any intervening toolkit library, it has sole +responsibility for interacting well with the many and varied window managers in +use on Unix-like systems. In order for applications and window managers to work +well together, a number of standards and conventions have been developed that +regulate behavior outside the scope of the X11 API; most importantly the +[Inter-Client Communication Conventions Manual][ICCCM] (ICCCM) and [Extended +Window Manager Hints][EWMH] (EWMH) standards. + +[ICCCM]: https://www.tronche.com/gui/x/icccm/ +[EWMH]: https://standards.freedesktop.org/wm-spec/wm-spec-latest.html GLFW uses the `_MOTIF_WM_HINTS` window property to support borderless windows. If the running window manager does not support this property, the @@ -50,16 +50,18 @@ compositing window manager to un-redirect full screen GLFW windows. If the running window manager uses compositing but does not support this property then additional copying may be performed for each buffer swap of full screen windows. -GLFW uses the -[clipboard manager protocol](https://www.freedesktop.org/wiki/ClipboardManager/) -to push a clipboard string (i.e. selection) owned by a GLFW window about to be -destroyed to the clipboard manager. If there is no running clipboard manager, -the clipboard string will be unavailable once the window has been destroyed. +GLFW uses the [clipboard manager protocol][ClipboardManager] to push a clipboard +string (i.e. selection) owned by a GLFW window about to be destroyed to the +clipboard manager. If there is no running clipboard manager, the clipboard +string will be unavailable once the window has been destroyed. -GLFW uses the -[X drag-and-drop protocol](https://www.freedesktop.org/wiki/Specifications/XDND/) -to provide file drop events. If the application originating the drag does not -support this protocol, drag and drop will not work. +[clipboardManager]: https://www.freedesktop.org/wiki/ClipboardManager/ + +GLFW uses the [X drag-and-drop protocol][XDND] to provide file drop events. If +the application originating the drag does not support this protocol, drag and +drop will not work. + +[XDND]: https://www.freedesktop.org/wiki/Specifications/XDND/ GLFW uses the XRandR 1.3 extension to provide multi-monitor support. If the running X server does not support this version of this extension, multi-monitor @@ -104,44 +106,49 @@ Wayland protocols to implement certain features if the compositor supports them. GLFW uses xkbcommon 0.5.0 to provide key and text input support. Earlier versions are not supported. -GLFW uses the [xdg-shell protocol](https://wayland.app/protocols/xdg-shell) -to provide better window management. This protocol is mandatory for GLFW to -display a window. +GLFW uses the [xdg-shell][] protocol to provide better window management. This +protocol is mandatory for GLFW to display a window. -GLFW uses the -[relative pointer protocol](https://wayland.app/protocols/relative-pointer-unstable-v1) -alongside the -[pointer constraints protocol](https://wayland.app/protocols/pointer-constraints-unstable-v1) -to implement disabled cursor. If the running compositor does not support both -of these protocols, disabling the cursor will have no effect. +[xdg-shell]: https://wayland.app/protocols/xdg-shell -GLFW uses the -[idle inhibit protocol](https://wayland.app/protocols/idle-inhibit-unstable-v1) -to prohibit the screensaver from starting. If the running compositor does not -support this protocol, the screensaver may start even for full screen windows. +GLFW uses the [relative-pointer-unstable-v1][] protocol alongside the +[pointer-constraints-unstable-v1][] protocol to implement disabled cursor. If +the running compositor does not support both of these protocols, disabling the +cursor will have no effect. -GLFW uses the -[libdecor library](https://gitlab.freedesktop.org/libdecor/libdecor) for window -decorations, where available. This in turn provides good quality client-side -decorations (drawn by the application) on desktop systems that do not support -server-side decorations (drawn by the window manager). On systems that do not -provide either libdecor or xdg-decoration, very basic window decorations are -provided. These do not include the window title or any caption buttons. +[relative-pointer-unstable-v1]: https://wayland.app/protocols/relative-pointer-unstable-v1 +[pointer-constraints-unstable-v1]: https://wayland.app/protocols/pointer-constraints-unstable-v1 -GLFW uses the -[xdg-decoration protocol](https://wayland.app/protocols/xdg-decoration-unstable-v1) -to request decorations to be drawn around its windows. This protocol is part -of wayland-protocols 1.15, and mandatory at build time. If the running -compositor does not support this protocol, a very simple frame will be drawn by -GLFW itself, using the -[viewporter protocol](https://wayland.app/protocols/viewporter) -alongside subsurfaces. If the running compositor does not support these -protocols either, no decorations will be drawn around windows. +GLFW uses the [idle-inhibit-unstable-v1][] protocol to prohibit the screensaver +from starting. If the running compositor does not support this protocol, the +screensaver may start even for full screen windows. -GLFW uses the [xdg-activation -protocol](https://wayland.app/protocols/xdg-activation-v1) -to implement window focus and attention requests. If the running compositor -does not support this protocol, window focus and attention requests do nothing. +[idle-inhibit-unstable-v1]: https://wayland.app/protocols/idle-inhibit-unstable-v1 + +GLFW uses the [libdecor][] library for window decorations, where available. +This in turn provides good quality client-side decorations (drawn by the +application) on desktop systems that do not support server-side decorations +(drawn by the window manager). On systems that do not provide either libdecor +or xdg-decoration, very basic window decorations are provided. These do not +include the window title or any caption buttons. + +[libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor + +GLFW uses the [xdg-decoration-unstable-v1][] protocol to request decorations to +be drawn around its windows. This protocol is part of wayland-protocols 1.15, +and mandatory at build time. If the running compositor does not support this +protocol, a very simple frame will be drawn by GLFW itself, using the +[viewporter][] protocol alongside subsurfaces. If the running compositor does +not support these protocols either, no decorations will be drawn around windows. + +[xdg-decoration-unstable-v1]: https://wayland.app/protocols/xdg-decoration-unstable-v1 +[viewporter]: https://wayland.app/protocols/viewporter + +GLFW uses the [xdg-activation-v1][] protocol to implement window focus and +attention requests. If the running compositor does not support this protocol, +window focus and attention requests do nothing. + +[xdg-activation-v1]: https://wayland.app/protocols/xdg-activation-v1 ## GLX extensions {#compat_glx} diff --git a/docs/compile.md b/docs/compile.md index 5703cf80..14c8bc10 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -19,8 +19,8 @@ GLFW uses [CMake](https://cmake.org/) to generate project files or makefiles for your chosen development environment. To compile GLFW, first generate these files with CMake and then use them to compile the GLFW library. -If you are on Windows and macOS you can -[download CMake](https://cmake.org/download/) from their site. +If you are on Windows and macOS you can [download +CMake](https://cmake.org/download/) from their site. If you are on a Unix-like system such as Linux, FreeBSD or Cygwin or have a package system like Fink, MacPorts or Homebrew, you can install its CMake @@ -28,9 +28,10 @@ package. CMake is a complex tool and this guide will only show a few of the possible ways to set up and compile GLFW. The CMake project has their own much more detailed -[CMake user guide](https://cmake.org/cmake/help/latest/guide/user-interaction/) -that includes everything in this guide not specific to GLFW. It may be a useful -companion to this one. +[CMake user guide][cmake-guide] that includes everything in this guide not +specific to GLFW. It may be a useful companion to this one. + +[cmake-guide]: https://cmake.org/cmake/help/latest/guide/user-interaction/ ### Installing dependencies {#compile_deps} @@ -263,10 +264,11 @@ __USE_MSVC_RUNTIME_LIBRARY_DLL__ determines whether to use the DLL version or th static library version of the Visual C++ runtime library. When enabled, the DLL version of the Visual C++ library is used. This is enabled by default. -On CMake 3.15 and later you can set the standard CMake -[CMAKE_MSVC_RUNTIME_LIBRARY](https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html) +On CMake 3.15 and later you can set the standard CMake [CMAKE_MSVC_RUNTIME_LIBRARY][] variable instead of this GLFW-specific option. +[CMAKE_MSVC_RUNTIME_LIBRARY]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html + @anchor GLFW_USE_HYBRID_HPG __GLFW_USE_HYBRID_HPG__ determines whether to export the `NvOptimusEnablement` and `AmdPowerXpressRequestHighPerformance` symbols, which force the use of the @@ -326,8 +328,9 @@ cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=CMake/x86_64-w64- The path to the toolchain file is relative to the path to the GLFW source tree passed to the `-S` flag, not to the current directory. -For more details see the -[CMake toolchain guide](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html). +For more details see the [CMake toolchain guide][cmake-toolchains]. + +[cmake-toolchains]: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html ## Compiling GLFW manually {#compile_manual} diff --git a/docs/input.md b/docs/input.md index 5915c227..56983b08 100644 --- a/docs/input.md +++ b/docs/input.md @@ -735,8 +735,10 @@ indication of where they are located on the device. Their order may also vary between platforms even with the same device. To solve this problem the SDL community crowdsourced the -[SDL_GameControllerDB](https://github.com/gabomdq/SDL_GameControllerDB) project, -a database of mappings from many different devices to an Xbox-like gamepad. +[SDL_GameControllerDB][] project, a database of mappings from many different +devices to an Xbox-like gamepad. + +[SDL_GameControllerDB]: https://github.com/gabomdq/SDL_GameControllerDB GLFW supports this mapping format and contains a copy of the mappings available at the time of release. See @ref gamepad_mapping for how to update @@ -811,9 +813,8 @@ the largest available index for each array. ### Gamepad mappings {#gamepad_mapping} -GLFW contains a copy of the mappings available in -[SDL_GameControllerDB](https://github.com/gabomdq/SDL_GameControllerDB) at the -time of release. Newer ones can be added at runtime with @ref +GLFW contains a copy of the mappings available in [SDL_GameControllerDB][] at +the time of release. Newer ones can be added at runtime with @ref glfwUpdateGamepadMappings. ```c diff --git a/docs/intro.md b/docs/intro.md index d30ab33c..54e6e5bb 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -105,14 +105,15 @@ glfwGetJoystickHats. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. @anchor GLFW_ANGLE_PLATFORM_TYPE_hint __GLFW_ANGLE_PLATFORM_TYPE__ specifies the platform type (rendering backend) to -request when using OpenGL ES and EGL via -[ANGLE](https://chromium.googlesource.com/angle/angle/). If the requested -platform type is unavailable, ANGLE will use its default. Possible values are -one of `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, +request when using OpenGL ES and EGL via [ANGLE][]. If the requested platform +type is unavailable, ANGLE will use its default. Possible values are one of +`GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and `GLFW_ANGLE_PLATFORM_TYPE_METAL`. +[ANGLE]: https://chromium.googlesource.com/angle/angle/ + The ANGLE platform type is specified via the `EGL_ANGLE_platform_angle` extension. This extension is not used if this hint is `GLFW_ANGLE_PLATFORM_TYPE_NONE`, which is the default value. @@ -145,11 +146,12 @@ the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and #### Wayland specific init hints {#init_hints_wayland} @anchor GLFW_WAYLAND_LIBDECOR_hint -__GLFW_WAYLAND_LIBDECOR__ specifies whether to use -[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor) for window +__GLFW_WAYLAND_LIBDECOR__ specifies whether to use [libdecor][] for window decorations where available. Possible values are `GLFW_WAYLAND_PREFER_LIBDECOR` and `GLFW_WAYLAND_DISABLE_LIBDECOR`. This is ignored on other platforms. +[libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor + #### Supported and default values {#init_hints_values} diff --git a/docs/moving.md b/docs/moving.md index d50b7ffe..7c1e2f5a 100644 --- a/docs/moving.md +++ b/docs/moving.md @@ -16,8 +16,9 @@ required to create full screen windows with GLFW 3. The GLFW 3 header is named @ref glfw3.h and moved to the `GLFW` directory, to avoid collisions with the headers of other major versions. Similarly, the GLFW 3 library is named `glfw3,` except when it's installed as a shared library on -Unix-like systems, where it uses the -[soname](https://en.wikipedia.org/wiki/soname) `libglfw.so.3`. +Unix-like systems, where it uses the [soname][] `libglfw.so.3`. + +[soname]: https://en.wikipedia.org/wiki/soname __Old syntax__ ```c @@ -36,18 +37,20 @@ The threading functions have been removed, including the per-thread sleep function. They were fairly primitive, under-used, poorly integrated and took time away from the focus of GLFW (i.e. context, input and window). There are better threading libraries available and native threading support is available -in both [C++11](https://en.cppreference.com/w/cpp/thread) and -[C11](https://en.cppreference.com/w/c/thread), both of which are gaining -traction. +in both [C++11][] and [C11][], both of which are gaining traction. + +[C++11]: https://en.cppreference.com/w/cpp/thread +[C11]: https://en.cppreference.com/w/c/thread If you wish to use the C++11 or C11 facilities but your compiler doesn't yet -support them, see the -[TinyThread++](https://gitorious.org/tinythread/tinythreadpp) and -[TinyCThread](https://github.com/tinycthread/tinycthread) projects created by +support them, see the [TinyThread++][] and [TinyCThread][] projects created by the original author of GLFW. These libraries implement a usable subset of the threading APIs in C++11 and C11, and in fact some GLFW 3 test programs use TinyCThread. +[TinyThread++]: https://gitorious.org/tinythread/tinythreadpp +[TinyCThread]: https://github.com/tinycthread/tinycthread + However, GLFW 3 has better support for _use from multiple threads_ than GLFW 2 had. Contexts can be made current on any thread, although only a single thread at a time, and the documentation explicitly states which functions may be @@ -84,13 +87,14 @@ __Removed functions__ ### Removal of GLFWCALL macro {#moving_stdcall} -The `GLFWCALL` macro, which made callback functions use -[\_\_stdcall](https://msdn.microsoft.com/en-us/library/zxk0tw93.aspx) on Windows, -has been removed. GLFW is written in C, not Pascal. Removing this macro means -there's one less thing for application programmers to remember, i.e. the -requirement to mark all callback functions with `GLFWCALL`. It also simplifies -the creation of DLLs and DLL link libraries, as there's no need to explicitly -disable `@n` entry point suffixes. +The `GLFWCALL` macro, which made callback functions use [\_\_stdcall][stdcall] +on Windows, has been removed. GLFW is written in C, not Pascal. Removing this +macro means there's one less thing for application programmers to remember, i.e. +the requirement to mark all callback functions with `GLFWCALL`. It also +simplifies the creation of DLLs and DLL link libraries, as there's no need to +explicitly disable `@n` entry point suffixes. + +[stdcall]: https://msdn.microsoft.com/en-us/library/zxk0tw93.aspx __Old syntax__ ```c @@ -109,7 +113,9 @@ Because GLFW 3 supports multiple windows, window handle parameters have been added to all window-related GLFW functions and callbacks. The handle of a newly created window is returned by @ref glfwCreateWindow (formerly `glfwOpenWindow`). Window handles are pointers to the -[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWwindow. +[opaque][opaque-type] type @ref GLFWwindow. + +[opaque-type]: https://en.wikipedia.org/wiki/Opaque_data_type __Old syntax__ ```c @@ -129,7 +135,7 @@ instead of passing `GLFW_FULLSCREEN` you specify which monitor you wish the window to use. The @ref glfwGetPrimaryMonitor function returns the monitor that GLFW 2 would have selected, but there are many other [monitor functions](@ref monitor_guide). Monitor handles are pointers to the -[opaque](https://en.wikipedia.org/wiki/Opaque_data_type) type @ref GLFWmonitor. +[opaque][opaque-type] type @ref GLFWmonitor. __Old basic full screen__ ```c @@ -376,14 +382,15 @@ glfwGetJoystickAxes and @ref glfwGetJoystickButtons functions. ### Win32 MBCS support {#moving_mbcs} -The Win32 port of GLFW 3 will not compile in -[MBCS mode](https://msdn.microsoft.com/en-us/library/5z097dxa.aspx). -However, because the use of the Unicode version of the Win32 API doesn't affect -the process as a whole, but only those windows created using it, it's perfectly +The Win32 port of GLFW 3 will not compile in [MBCS mode][MBCS]. However, +because the use of the Unicode version of the Win32 API doesn't affect the +process as a whole, but only those windows created using it, it's perfectly possible to call MBCS functions from other parts of the same application. Therefore, even if an application using GLFW has MBCS mode code, there's no need for GLFW itself to support it. +[MBCS]: https://msdn.microsoft.com/en-us/library/5z097dxa.aspx + ### Support for versions of Windows older than XP {#moving_windows} @@ -429,10 +436,12 @@ invalidating any window handles you may still have. ### GLU header inclusion {#moving_glu} GLFW 3 does not by default include the GLU header and GLU itself has been -deprecated by [Khronos](https://en.wikipedia.org/wiki/Khronos_Group). __New -projects should not use GLU__, but if you need it for legacy code that -has been moved to GLFW 3, you can request that the GLFW header includes it by -defining @ref GLFW_INCLUDE_GLU before the inclusion of the GLFW header. +deprecated by [Khronos][]. __New projects should not use GLU__, but if you need +it for legacy code that has been moved to GLFW 3, you can request that the GLFW +header includes it by defining @ref GLFW_INCLUDE_GLU before the inclusion of the +GLFW header. + +[Khronos]: https://en.wikipedia.org/wiki/Khronos_Group __Old syntax__ ```c @@ -446,11 +455,13 @@ __New syntax__ ``` There are many libraries that offer replacements for the functionality offered -by GLU. For the matrix helper functions, see math libraries like -[GLM](https://github.com/g-truc/glm) (for C++), -[linmath.h](https://github.com/datenwolf/linmath.h) (for C) and others. For the -tessellation functions, see for example -[libtess2](https://github.com/memononen/libtess2). +by GLU. For the matrix helper functions, see math libraries like [GLM][] (for +C++), [linmath.h][] (for C) and others. For the tessellation functions, see for +example [libtess2][]. + +[GLM]: https://github.com/g-truc/glm +[linmath.h]: https://github.com/datenwolf/linmath.h +[libtess2]: https://github.com/memononen/libtess2 ## Name change tables {#moving_tables} diff --git a/docs/news.md b/docs/news.md index 7e9c4ed6..0dbbd5ad 100644 --- a/docs/news.md +++ b/docs/news.md @@ -61,10 +61,11 @@ GLFW now supports specifying the app_id for a Wayland window using the GLFW now provides the [GLFW_ANGLE_PLATFORM_TYPE](@ref GLFW_ANGLE_PLATFORM_TYPE_hint) init hint for -requesting a specific rendering backend when using -[ANGLE](https://chromium.googlesource.com/angle/angle/) to create OpenGL ES +requesting a specific rendering backend when using [ANGLE][] to create OpenGL ES contexts. +[ANGLE]: https://chromium.googlesource.com/angle/angle/ + #### Captured cursor mode {#captured_cursor_34} diff --git a/docs/quick.md b/docs/quick.md index f3498231..6f487fc3 100644 --- a/docs/quick.md +++ b/docs/quick.md @@ -336,13 +336,14 @@ presses _Escape_ or closes the window. @snippet triangle-opengl.c code -The program above can be found in the -[source package](https://www.glfw.org/download.html) as +The program above can be found in the [source package][download] 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 you already have this as `triangle-opengl.exe` on Windows, `triangle-opengl` on Linux or `triangle-opengl.app` on macOS. +[download]: https://www.glfw.org/download.html + 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 functions for that category. diff --git a/docs/window.md b/docs/window.md index 8ab7051f..ecb9c359 100644 --- a/docs/window.md +++ b/docs/window.md @@ -406,8 +406,9 @@ mode, which may provide additional error and diagnostic reporting functionality. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. Debug contexts for OpenGL and OpenGL ES are described in detail by the -[GL_KHR_debug](https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt) -extension. +[GL_KHR_debug][] extension. + +[GL_KHR_debug]: https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt @note `GLFW_CONTEXT_DEBUG` is the new name introduced in GLFW 3.4. The older `GLFW_OPENGL_DEBUG_CONTEXT` name is also available for compatibility. @@ -440,8 +441,9 @@ current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will not be flushed on release. Context release behaviors are described in detail by the -[GL_KHR_context_flush_control](https://www.opengl.org/registry/specs/KHR/context_flush_control.txt) -extension. +[GL_KHR_context_flush_control][] extension. + +[GL_KHR_context_flush_control]: https://www.opengl.org/registry/specs/KHR/context_flush_control.txt @anchor GLFW_CONTEXT_NO_ERROR_hint __GLFW_CONTEXT_NO_ERROR__ specifies whether errors should be generated by the @@ -449,8 +451,9 @@ context. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled, situations that would have generated errors instead cause undefined behavior. The no error mode for OpenGL and OpenGL ES is described in detail by the -[GL_KHR_no_error](https://www.opengl.org/registry/specs/KHR/no_error.txt) -extension. +[GL_KHR_no_error][] extension. + +[GL_KHR_no_error]: https://www.opengl.org/registry/specs/KHR/no_error.txt #### Win32 specific hints {#window_hints_win32} diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index d40126ae..84fa49e2 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2648,9 +2648,10 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, * specified monitor. * * Some platforms do not provide accurate monitor size information, either - * because the monitor - * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data) - * data is incorrect or because the driver does not report it accurately. + * because the monitor [EDID][] data is incorrect or because the driver does + * not report it accurately. + * + * [EDID]: https://en.wikipedia.org/wiki/Extended_display_identification_data * * Any or all of the size arguments may be `NULL`. If an error occurs, all * non-`NULL` size arguments will be set to zero. @@ -3160,18 +3161,21 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * @remark @macos The GLFW window has no icon, as it is not a document * window, but the dock icon will be the same as the application bundle's icon. * For more information on bundles, see the - * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) - * in the Mac Developer Library. + * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library. + * + * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/ * * @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) * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the * application bundle's `Info.plist`. For more information, see - * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html) - * in the Mac Developer Library. The GLFW test and example programs use - * a custom `Info.plist` template for this, which can be found as - * `CMake/Info.plist.in` in the source tree. + * [High Resolution Guidelines for OS X][hidpi-guide] in the Mac Developer + * Library. The GLFW test and example programs use a custom `Info.plist` + * template for this, which can be found as `CMake/Info.plist.in` in the source + * tree. + * + * [hidpi-guide]: https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html * * @remark @macos When activating frame autosaving with * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified @@ -3345,8 +3349,9 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); * @remark @macos Regular windows do not have icons on macOS. This function * will emit @ref GLFW_FEATURE_UNAVAILABLE. The dock icon will be the same as * the application bundle's icon. For more information on bundles, see the - * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) - * in the Mac Developer Library. + * [Bundle Programming Guide][bundle-guide] in the Mac Developer Library. + * + * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/ * * @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. From a9cc7c7260c32068a5374ce9d59515df540de970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Feb 2024 20:04:14 +0100 Subject: [PATCH 085/137] Add GLFW_SCALE_FRAMEBUFFER window hint This adds the GLFW_SCALE_FRAMEBUFFER window hint, enabling control of framebuffer scaling across Wayland and macOS. On macOS, this window hint is a new name for GLFW_COCOA_RETINA_FRAMEBUFFER, and both hint names will modify the same hint. This is now a more symmetric counterpart to GLFW_SCALE_TO_MONITOR and, weirdly, they each apply neatly to half of the supported platforms. This commit is mostly documentation updates to better integrate and contrast these two scaling mechanisms. --- README.md | 1 + docs/monitor.md | 12 ++------ docs/news.md | 17 ++++++++++++ docs/window.md | 65 +++++++++++++++++++++++++++++++------------- include/GLFW/glfw3.h | 13 +++++++-- src/cocoa_platform.h | 2 +- src/cocoa_window.m | 6 ++-- src/internal.h | 2 +- src/nsgl_context.m | 2 +- src/window.c | 11 ++++---- src/wl_platform.h | 1 + src/wl_window.c | 4 +++ 12 files changed, 92 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index b7758557..a05f62c0 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,7 @@ information on what to include when reporting a bug. content area (#58) - Added `GLFW_POSITION_X` and `GLFW_POSITION_Y` window hints for initial position (#1603,#1747) + - Added `GLFW_SCALE_FRAMEBUFFER` window hint for Wayland and macOS scaling (#2457) - Added `GLFW_ANY_POSITION` hint value for letting the window manager choose (#1603,#1747) - Added `GLFW_PLATFORM_UNAVAILABLE` error for platform detection failures (#1958) - Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692) diff --git a/docs/monitor.md b/docs/monitor.md index d6d83cb3..12d98541 100644 --- a/docs/monitor.md +++ b/docs/monitor.md @@ -150,16 +150,8 @@ float xscale, yscale; glfwGetMonitorContentScale(monitor, &xscale, &yscale); ``` -The content scale is the ratio between the current DPI and the platform's -default DPI. This is especially important for text and any UI elements. If the -pixel dimensions of your UI scaled by this look appropriate on your machine then -it should appear at a reasonable size on other machines regardless of their DPI -and scaling settings. This relies on the system DPI and scaling settings being -somewhat correct. - -The content scale may depend on both the monitor resolution and pixel density -and on user settings. It may be very different from the raw DPI calculated from -the physical size and current resolution. +For more information on what the content scale is and how to use it, see +[window content scale](@ref window_scale). ### Virtual position {#monitor_pos} diff --git a/docs/news.md b/docs/news.md index 0dbbd5ad..7842ddf5 100644 --- a/docs/news.md +++ b/docs/news.md @@ -85,6 +85,22 @@ function pointers corresponding to the standard library functions `malloc`, For more information see @ref init_allocator. +#### Window hint for framebuffer scaling {#scale_framebuffer_34} + +GLFW now allows provides the +[GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for +controlling framebuffer scaling on platforms that handle scaling by keeping the +window size the same while resizing the framebuffer. The default value is to +allow framebuffer scaling. + +This was already possible on macOS via the +[GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) window +hint. This hint is now another name for +[GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint). + +For more information, see @ref window_scale. + + #### Window hints for initial position {#features_34_position_hint} GLFW now provides the @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints for @@ -288,6 +304,7 @@ then GLFW will fail to initialize. - @ref GLFW_WAYLAND_LIBDECOR - @ref GLFW_WAYLAND_PREFER_LIBDECOR - @ref GLFW_WAYLAND_DISABLE_LIBDECOR + - @ref GLFW_SCALE_FRAMEBUFFER ## Release notes for earlier versions {#news_archive} diff --git a/docs/window.md b/docs/window.md index ecb9c359..f4e153c3 100644 --- a/docs/window.md +++ b/docs/window.md @@ -239,13 +239,28 @@ focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and @anchor GLFW_SCALE_TO_MONITOR __GLFW_SCALE_TO_MONITOR__ specified whether the window content area should be -resized based on the [monitor content scale](@ref monitor_scale) of any monitor -it is placed on. This includes the initial placement when the window is -created. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. +resized based on [content scale](@ref window_scale) changes. This can be +because of a global user settings change or because the window was moved to +a monitor with different scale settings. This hint only has an effect on platforms where screen coordinates and pixels -always map 1:1 such as Windows and X11. On platforms like macOS the resolution -of the framebuffer is changed independently of the window size. +always map 1:1, such as Windows and X11. On platforms like macOS the resolution +of the framebuffer can change independently of the window size. + +@anchor GLFW_SCALE_FRAMEBUFFER_hint +@anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint +__GLFW_SCALE_FRAMEBUFFER__ specifies whether the framebuffer should be resized +based on [content scale](@ref window_scale) changes. This can be +because of a global user settings change or because the window was moved to +a monitor with different scale settings. + +This hint only has an effect on platforms where screen coordinates can be scaled +relative to pixel coordinates, such as macOS and Wayland. On platforms like +Windows and X11 the framebuffer and window content area sizes always map 1:1. + +This is the new name, introduced in GLFW 3.4. The older +`GLFW_COCOA_RETINA_FRAMEBUFFER` name is also available for compatibility. Both +names modify the same hint value. @anchor GLFW_MOUSE_PASSTHROUGH_hint __GLFW_MOUSE_PASSTHROUGH__ specifies whether the window is transparent to mouse @@ -474,11 +489,6 @@ GLFW behaves as if this hint was set to `GLFW_FALSE`. Possible values are #### macOS specific hints {#window_hints_osx} -@anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint -__GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution -framebuffers on Retina displays. Possible values are `GLFW_TRUE` and -`GLFW_FALSE`. This is ignored on other platforms. - @anchor GLFW_COCOA_FRAME_NAME_hint __GLFW_COCOA_FRAME_NAME__ specifies the UTF-8 encoded name to use for autosaving the window frame, or if empty disables frame autosaving for the window. This is @@ -533,6 +543,7 @@ GLFW_CENTER_CURSOR | `GLFW_TRUE` | `GLFW_TRUE` or `GL GLFW_TRANSPARENT_FRAMEBUFFER | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_FOCUS_ON_SHOW | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_SCALE_TO_MONITOR | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` +GLFW_SCALE_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_MOUSE_PASSTHROUGH | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_POSITION_X | `GLFW_ANY_POSITION` | Any valid screen x-coordinate or `GLFW_ANY_POSITION` GLFW_POSITION_Y | `GLFW_ANY_POSITION` | Any valid screen y-coordinate or `GLFW_ANY_POSITION` @@ -563,7 +574,6 @@ GLFW_CONTEXT_DEBUG | `GLFW_FALSE` | `GLFW_TRUE` or `GL 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_WIN32_SHOWDEFAULT | `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` GLFW_X11_CLASS_NAME | `""` | An ASCII encoded `WM_CLASS` class name @@ -736,16 +746,21 @@ float xscale, yscale; glfwGetWindowContentScale(window, &xscale, &yscale); ``` -The content scale is the ratio between the current DPI and the platform's -default DPI. This is especially important for text and any UI elements. If the -pixel dimensions of your UI scaled by this look appropriate on your machine then -it should appear at a reasonable size on other machines regardless of their DPI -and scaling settings. This relies on the system DPI and scaling settings being -somewhat correct. +The content scale can be thought of as the ratio between the current DPI and the +platform's default DPI. It is intended to be a scaling factor to apply to the +pixel dimensions of text and other UI elements. If the dimensions scaled by +this factor looks appropriate on your machine then it should appear at +a reasonable size on other machines with different DPI and scaling settings. + +This relies on the DPI and scaling settings on both machines being appropriate. + +The content scale may depend on both the monitor resolution and pixel density +and on user settings like DPI or a scaling percentage. It may be very different +from the raw DPI calculated from the physical size and current resolution. On systems where each monitors can have its own content scale, the window -content scale will depend on which monitor the system considers the window to be -on. +content scale will depend on which monitor or monitors the system considers the +window to be "on". If you wish to be notified when the content scale of a window changes, whether because of a system setting change or because it was moved to a monitor with @@ -770,6 +785,18 @@ with a different content scale. To have this done automatically both when the window is created and when its content scale later changes, set the @ref GLFW_SCALE_TO_MONITOR window hint. +On platforms where pixels do not necessarily equal screen coordinates, the +framebuffer will instead need to be sized to provide a full resolution image +for the window. When the window moves between monitors with different content +scales, the window size will remain the same but the framebuffer size will +change. This is done automatically by default. To disable this resizing, set +the @ref GLFW_SCALE_FRAMEBUFFER window hint. + +Both of these hints also apply when the window is created. Every window starts +out with a content scale of one. A window with one or both of these hints set +will adapt to the appropriate scale in the process of being created, set up and +shown. + ### Window size limits {#window_sizelimits} diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 84fa49e2..66edf4fc 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1098,8 +1098,15 @@ extern "C" { * [window hint](@ref GLFW_SCALE_TO_MONITOR). */ #define GLFW_SCALE_TO_MONITOR 0x0002200C -/*! @brief macOS specific - * [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint). +/*! @brief Window framebuffer scaling + * [window hint](@ref GLFW_SCALE_FRAMEBUFFER_hint). + */ +#define GLFW_SCALE_FRAMEBUFFER 0x0002200D +/*! @brief Legacy name for compatibility. + * + * This is an alias for the + * [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for + * compatibility with earlier versions. */ #define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001 /*! @brief macOS specific @@ -3167,7 +3174,7 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * @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) + * [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the * application bundle's `Info.plist`. For more information, see * [High Resolution Guidelines for OS X][hidpi-guide] in the Mac Developer diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 9f7d191d..3d424ee7 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -145,7 +145,7 @@ typedef struct _GLFWwindowNS GLFWbool maximized; GLFWbool occluded; - GLFWbool retina; + GLFWbool scaleFramebuffer; // Cached window properties to filter out duplicate events int width, height; diff --git a/src/cocoa_window.m b/src/cocoa_window.m index f6639646..7e90cf99 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -513,7 +513,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; if (xscale != window->ns.xscale || yscale != window->ns.yscale) { - if (window->ns.retina && window->ns.layer) + if (window->ns.scaleFramebuffer && window->ns.layer) [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; window->ns.xscale = xscale; @@ -872,7 +872,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, [window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)]; window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window]; - window->ns.retina = wndconfig->ns.retina; + window->ns.scaleFramebuffer = wndconfig->scaleFramebuffer; if (fbconfig->transparent) { @@ -1969,7 +1969,7 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, return VK_ERROR_EXTENSION_NOT_PRESENT; } - if (window->ns.retina) + if (window->ns.scaleFramebuffer) [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]]; [window->ns.view setLayer:window->ns.layer]; diff --git a/src/internal.h b/src/internal.h index caf93675..c6c856f1 100644 --- a/src/internal.h +++ b/src/internal.h @@ -402,8 +402,8 @@ struct _GLFWwndconfig GLFWbool focusOnShow; GLFWbool mousePassthrough; GLFWbool scaleToMonitor; + GLFWbool scaleFramebuffer; struct { - GLFWbool retina; char frameName[256]; } ns; struct { diff --git a/src/nsgl_context.m b/src/nsgl_context.m index e838caa2..d19622c6 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -333,7 +333,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, forParameter:NSOpenGLContextParameterSurfaceOpacity]; } - [window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina]; + [window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.scaleFramebuffer]; [window->context.nsgl.object setView:window->ns.view]; diff --git a/src/window.c b/src/window.c index 0e279336..3b8d706e 100644 --- a/src/window.c +++ b/src/window.c @@ -274,6 +274,7 @@ void glfwDefaultWindowHints(void) _glfw.hints.window.focusOnShow = GLFW_TRUE; _glfw.hints.window.xpos = GLFW_ANY_POSITION; _glfw.hints.window.ypos = GLFW_ANY_POSITION; + _glfw.hints.window.scaleFramebuffer = GLFW_TRUE; // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil, // double buffered @@ -288,9 +289,6 @@ void glfwDefaultWindowHints(void) // The default is to select the highest available refresh rate _glfw.hints.refreshRate = GLFW_DONT_CARE; - - // The default is to use full Retina resolution framebuffers - _glfw.hints.window.ns.retina = GLFW_TRUE; } GLFWAPI void glfwWindowHint(int hint, int value) @@ -374,9 +372,6 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_POSITION_Y: _glfw.hints.window.ypos = value; return; - 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; @@ -389,6 +384,10 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_SCALE_TO_MONITOR: _glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE; return; + case GLFW_SCALE_FRAMEBUFFER: + case GLFW_COCOA_RETINA_FRAMEBUFFER: + _glfw.hints.window.scaleFramebuffer = value ? GLFW_TRUE : GLFW_FALSE; + return; case GLFW_CENTER_CURSOR: _glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE; return; diff --git a/src/wl_platform.h b/src/wl_platform.h index 3b9a3a3c..cb9b170f 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -355,6 +355,7 @@ typedef struct _GLFWwindowWayland GLFWbool fullscreen; GLFWbool hovered; GLFWbool transparent; + GLFWbool scaleFramebuffer; struct wl_surface* surface; struct wl_callback* callback; diff --git a/src/wl_window.c b/src/wl_window.c index 06b0256f..0a1554d1 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -369,6 +369,9 @@ void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window) return; } + if (!window->wl.scaleFramebuffer) + return; + // Get the scale factor from the highest scale monitor. int32_t maxScale = 1; @@ -980,6 +983,7 @@ static GLFWbool createNativeSurface(_GLFWwindow* window, window->wl.bufferScale = 1; window->wl.title = _glfw_strdup(wndconfig->title); window->wl.appId = _glfw_strdup(wndconfig->wl.appId); + window->wl.scaleFramebuffer = wndconfig->scaleFramebuffer; window->wl.maximized = wndconfig->maximized; From 2b3f919b6055e6837ca0fad193c7f96b323f1256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 8 Feb 2024 22:08:31 +0100 Subject: [PATCH 086/137] Wayland: Add support for fractional scaling This adds basic support for fractional-scale-v1. Note that this introduces a potential discrepancy between window and monitor content scales. --- README.md | 1 + deps/wayland/fractional-scale-v1.xml | 102 +++++++++++++++++++++++++++ docs/compat.md | 8 +++ include/GLFW/glfw3.h | 3 + src/CMakeLists.txt | 1 + src/wl_init.c | 14 ++++ src/wl_platform.h | 7 ++ src/wl_window.c | 87 +++++++++++++++++++++-- 8 files changed, 216 insertions(+), 7 deletions(-) create mode 100644 deps/wayland/fractional-scale-v1.xml diff --git a/README.md b/README.md index a05f62c0..948b3212 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ information on what to include when reporting a bug. would abort (#1649) - [Wayland] Added support for `glfwRequestWindowAttention` (#2287) - [Wayland] Added support for `glfwFocusWindow` + - [Wayland] Added support for fractional scaling of window contents - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [Wayland] Bugfix: `GLFW_HOVERED` was true when the cursor was over any diff --git a/deps/wayland/fractional-scale-v1.xml b/deps/wayland/fractional-scale-v1.xml new file mode 100644 index 00000000..350bfc01 --- /dev/null +++ b/deps/wayland/fractional-scale-v1.xml @@ -0,0 +1,102 @@ + + + + Copyright © 2022 Kenny Levinsen + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + This protocol allows a compositor to suggest for surfaces to render at + fractional scales. + + A client can submit scaled content by utilizing wp_viewport. This is done by + creating a wp_viewport object for the surface and setting the destination + rectangle to the surface size before the scale factor is applied. + + The buffer size is calculated by multiplying the surface size by the + intended scale. + + The wl_surface buffer scale should remain set to 1. + + If a surface has a surface-local size of 100 px by 50 px and wishes to + submit buffers with a scale of 1.5, then a buffer of 150px by 75 px should + be used and the wp_viewport destination rectangle should be 100 px by 50 px. + + For toplevel surfaces, the size is rounded halfway away from zero. The + rounding algorithm for subsurface position and size is not defined. + + + + + A global interface for requesting surfaces to use fractional scales. + + + + + Informs the server that the client will not be using this protocol + object anymore. This does not affect any other objects, + wp_fractional_scale_v1 objects included. + + + + + + + + + + Create an add-on object for the the wl_surface to let the compositor + request fractional scales. If the given wl_surface already has a + wp_fractional_scale_v1 object associated, the fractional_scale_exists + protocol error is raised. + + + + + + + + + An additional interface to a wl_surface object which allows the compositor + to inform the client of the preferred scale. + + + + + Destroy the fractional scale object. When this object is destroyed, + preferred_scale events will no longer be sent. + + + + + + Notification of a new preferred scale for this surface that the + compositor suggests that the client should use. + + The sent scale is the numerator of a fraction with a denominator of 120. + + + + + diff --git a/docs/compat.md b/docs/compat.md index 202b8a4e..ef64b0cc 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -150,6 +150,14 @@ window focus and attention requests do nothing. [xdg-activation-v1]: https://wayland.app/protocols/xdg-activation-v1 +GLFW uses the [fractional-scale-v1][] protocol to implement fine-grained +framebuffer scaling. If the running compositor does not support this protocol, +the @ref GLFW_SCALE_FRAMEBUFFER window hint will only be able to scale the +framebuffer by integer scales. This will typically be the smallest integer not +less than the actual scale. + +[fractional-scale-v1]: https://wayland.app/protocols/fractional-scale-v1 + ## GLX extensions {#compat_glx} diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 66edf4fc..6423d61f 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2705,6 +2705,9 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * + * @remark @wayland Fractional scaling information is not yet available for + * monitors, so this function only returns integer content scales. + * * @thread_safety This function must only be called from the main thread. * * @sa @ref monitor_scale diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 45941647..1057a6f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,6 +101,7 @@ if (GLFW_BUILD_WAYLAND) generate_wayland_protocol("idle-inhibit-unstable-v1.xml") generate_wayland_protocol("pointer-constraints-unstable-v1.xml") generate_wayland_protocol("relative-pointer-unstable-v1.xml") + generate_wayland_protocol("fractional-scale-v1.xml") generate_wayland_protocol("xdg-activation-v1.xml") generate_wayland_protocol("xdg-decoration-unstable-v1.xml") endif() diff --git a/src/wl_init.c b/src/wl_init.c index 2644e89a..3aff476d 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -46,6 +46,7 @@ #include "viewporter-client-protocol.h" #include "relative-pointer-unstable-v1-client-protocol.h" #include "pointer-constraints-unstable-v1-client-protocol.h" +#include "fractional-scale-v1-client-protocol.h" #include "xdg-activation-v1-client-protocol.h" #include "idle-inhibit-unstable-v1-client-protocol.h" @@ -78,6 +79,10 @@ #include "pointer-constraints-unstable-v1-client-protocol-code.h" #undef types +#define types _glfw_fractional_scale_types +#include "fractional-scale-v1-client-protocol-code.h" +#undef types + #define types _glfw_xdg_activation_types #include "xdg-activation-v1-client-protocol-code.h" #undef types @@ -189,6 +194,13 @@ static void registryHandleGlobal(void* userData, &xdg_activation_v1_interface, 1); } + else if (strcmp(interface, "wp_fractional_scale_manager_v1") == 0) + { + _glfw.wl.fractionalScaleManager = + wl_registry_bind(registry, name, + &wp_fractional_scale_manager_v1_interface, + 1); + } } static void registryHandleGlobalRemove(void* userData, @@ -969,6 +981,8 @@ void _glfwTerminateWayland(void) zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager); if (_glfw.wl.activationManager) xdg_activation_v1_destroy(_glfw.wl.activationManager); + if (_glfw.wl.fractionalScaleManager) + wp_fractional_scale_manager_v1_destroy(_glfw.wl.fractionalScaleManager); if (_glfw.wl.registry) wl_registry_destroy(_glfw.wl.registry); if (_glfw.wl.display) diff --git a/src/wl_platform.h b/src/wl_platform.h index cb9b170f..76d7c9cb 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -131,6 +131,8 @@ struct wl_output; #define xdg_wm_base_interface _glfw_xdg_wm_base_interface #define xdg_activation_v1_interface _glfw_xdg_activation_v1_interface #define xdg_activation_token_v1_interface _glfw_xdg_activation_token_v1_interface +#define wl_surface_interface _glfw_wl_surface_interface +#define wp_fractional_scale_v1_interface _glfw_wp_fractional_scale_v1_interface #define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl; #define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl; @@ -395,6 +397,10 @@ typedef struct _GLFWwindowWayland size_t outputScaleCount; size_t outputScaleSize; + struct wp_viewport* scalingViewport; + uint32_t scalingNumerator; + struct wp_fractional_scale_v1* fractionalScale; + struct zwp_relative_pointer_v1* relativePointer; struct zwp_locked_pointer_v1* lockedPointer; struct zwp_confined_pointer_v1* confinedPointer; @@ -431,6 +437,7 @@ typedef struct _GLFWlibraryWayland struct zwp_pointer_constraints_v1* pointerConstraints; struct zwp_idle_inhibit_manager_v1* idleInhibitManager; struct xdg_activation_v1* activationManager; + struct wp_fractional_scale_manager_v1* fractionalScaleManager; _GLFWofferWayland* offers; unsigned int offerCount; diff --git a/src/wl_window.c b/src/wl_window.c index 0a1554d1..8a402a43 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -50,6 +50,7 @@ #include "pointer-constraints-unstable-v1-client-protocol.h" #include "xdg-activation-v1-client-protocol.h" #include "idle-inhibit-unstable-v1-client-protocol.h" +#include "fractional-scale-v1-client-protocol.h" #define GLFW_BORDER_SIZE 4 #define GLFW_CAPTION_HEIGHT 24 @@ -312,8 +313,16 @@ static void setContentAreaOpaque(_GLFWwindow* window) static void resizeFramebuffer(_GLFWwindow* window) { - window->wl.fbWidth = window->wl.width * window->wl.bufferScale; - window->wl.fbHeight = window->wl.height * window->wl.bufferScale; + if (window->wl.fractionalScale) + { + window->wl.fbWidth = (window->wl.width * window->wl.scalingNumerator) / 120; + window->wl.fbHeight = (window->wl.height * window->wl.scalingNumerator) / 120; + } + else + { + window->wl.fbWidth = window->wl.width * window->wl.bufferScale; + window->wl.fbHeight = window->wl.height * window->wl.bufferScale; + } if (window->wl.egl.window) { @@ -333,6 +342,13 @@ static void resizeWindow(_GLFWwindow* window) { resizeFramebuffer(window); + if (window->wl.scalingViewport) + { + wp_viewport_set_destination(window->wl.scalingViewport, + window->wl.width, + window->wl.height); + } + if (window->wl.fallback.decorations) { wp_viewport_set_destination(window->wl.fallback.top.viewport, @@ -372,6 +388,10 @@ void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window) if (!window->wl.scaleFramebuffer) return; + // When using fractional scaling, the buffer scale should remain at 1 + if (window->wl.fractionalScale) + return; + // Get the scale factor from the highest scale monitor. int32_t maxScale = 1; @@ -505,6 +525,25 @@ static void releaseMonitor(_GLFWwindow* window) } } +void fractionalScaleHandlePreferredScale(void* userData, + struct wp_fractional_scale_v1* fractionalScale, + uint32_t numerator) +{ + _GLFWwindow* window = userData; + + window->wl.scalingNumerator = numerator; + _glfwInputWindowContentScale(window, numerator / 120.f, numerator / 120.f); + resizeFramebuffer(window); + + if (window->wl.visible) + _glfwInputWindowDamage(window); +} + +const struct wp_fractional_scale_v1_listener fractionalScaleListener = +{ + fractionalScaleHandlePreferredScale, +}; + static void xdgToplevelHandleConfigure(void* userData, struct xdg_toplevel* toplevel, int32_t width, @@ -980,9 +1019,11 @@ static GLFWbool createNativeSurface(_GLFWwindow* window, window->wl.height = wndconfig->height; window->wl.fbWidth = wndconfig->width; window->wl.fbHeight = wndconfig->height; - window->wl.bufferScale = 1; window->wl.title = _glfw_strdup(wndconfig->title); window->wl.appId = _glfw_strdup(wndconfig->wl.appId); + + window->wl.bufferScale = 1; + window->wl.scalingNumerator = 120; window->wl.scaleFramebuffer = wndconfig->scaleFramebuffer; window->wl.maximized = wndconfig->maximized; @@ -991,6 +1032,28 @@ static GLFWbool createNativeSurface(_GLFWwindow* window, if (!window->wl.transparent) setContentAreaOpaque(window); + if (_glfw.wl.fractionalScaleManager) + { + if (window->wl.scaleFramebuffer) + { + window->wl.scalingViewport = + wp_viewporter_get_viewport(_glfw.wl.viewporter, window->wl.surface); + + wp_viewport_set_destination(window->wl.scalingViewport, + window->wl.width, + window->wl.height); + + window->wl.fractionalScale = + wp_fractional_scale_manager_v1_get_fractional_scale( + _glfw.wl.fractionalScaleManager, + window->wl.surface); + + wp_fractional_scale_v1_add_listener(window->wl.fractionalScale, + &fractionalScaleListener, + window); + } + } + return GLFW_TRUE; } @@ -2315,10 +2378,20 @@ void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, void _glfwGetWindowContentScaleWayland(_GLFWwindow* window, float* xscale, float* yscale) { - if (xscale) - *xscale = (float) window->wl.bufferScale; - if (yscale) - *yscale = (float) window->wl.bufferScale; + if (window->wl.fractionalScale) + { + if (xscale) + *xscale = (float) window->wl.scalingNumerator / 120.f; + if (yscale) + *yscale = (float) window->wl.scalingNumerator / 120.f; + } + else + { + if (xscale) + *xscale = (float) window->wl.bufferScale; + if (yscale) + *yscale = (float) window->wl.bufferScale; + } } void _glfwIconifyWindowWayland(_GLFWwindow* window) From a650c69cff4f9bdbb65365925558075a241e2fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Feb 2024 17:24:39 +0100 Subject: [PATCH 087/137] Wayland: Decide final window size in one place --- src/wl_window.c | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 8a402a43..ede4d659 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -338,8 +338,14 @@ static void resizeFramebuffer(_GLFWwindow* window) _glfwInputFramebufferSize(window, window->wl.fbWidth, window->wl.fbHeight); } -static void resizeWindow(_GLFWwindow* window) +static GLFWbool resizeWindow(_GLFWwindow* window, int width, int height) { + if (width == window->wl.width && height == window->wl.height) + return GLFW_FALSE; + + window->wl.width = width; + window->wl.height = height; + resizeFramebuffer(window); if (window->wl.scalingViewport) @@ -375,6 +381,8 @@ static void resizeWindow(_GLFWwindow* window) GLFW_BORDER_SIZE); wl_surface_commit(window->wl.fallback.bottom.surface); } + + return GLFW_TRUE; } void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window) @@ -651,13 +659,9 @@ static void xdgSurfaceHandleConfigure(void* userData, } } - if (width != window->wl.width || height != window->wl.height) + if (resizeWindow(window, width, height)) { - window->wl.width = width; - window->wl.height = height; - resizeWindow(window); - - _glfwInputWindowSize(window, width, height); + _glfwInputWindowSize(window, window->wl.width, window->wl.height); if (window->wl.visible) _glfwInputWindowDamage(window); @@ -752,13 +756,9 @@ void libdecorFrameHandleConfigure(struct libdecor_frame* frame, damaged = GLFW_TRUE; } - if (width != window->wl.width || height != window->wl.height) + if (resizeWindow(window, width, height)) { - window->wl.width = width; - window->wl.height = height; - resizeWindow(window); - - _glfwInputWindowSize(window, width, height); + _glfwInputWindowSize(window, window->wl.width, window->wl.height); damaged = GLFW_TRUE; } @@ -2250,13 +2250,13 @@ void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height) } else { - window->wl.width = width; - window->wl.height = height; - resizeWindow(window); + if (!resizeWindow(window, width, height)) + return; if (window->wl.libdecor.frame) { - struct libdecor_state* frameState = libdecor_state_new(width, height); + struct libdecor_state* frameState = + libdecor_state_new(window->wl.width, window->wl.height); libdecor_frame_commit(window->wl.libdecor.frame, frameState, NULL); libdecor_state_free(frameState); } @@ -2330,20 +2330,17 @@ void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom) width *= targetRatio; } - if (width != window->wl.width || height != window->wl.height) + if (resizeWindow(window, width, height)) { - window->wl.width = width; - window->wl.height = height; - resizeWindow(window); - if (window->wl.libdecor.frame) { - struct libdecor_state* frameState = libdecor_state_new(width, height); + struct libdecor_state* frameState = + libdecor_state_new(window->wl.width, window->wl.height); libdecor_frame_commit(window->wl.libdecor.frame, frameState, NULL); libdecor_state_free(frameState); } - _glfwInputWindowSize(window, width, height); + _glfwInputWindowSize(window, window->wl.width, window->wl.height); if (window->wl.visible) _glfwInputWindowDamage(window); From b61f3fc4796a5b998d70aeb5e4723ea8b681403d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Feb 2024 17:26:21 +0100 Subject: [PATCH 088/137] Wayland: Fix invalid size protocol error This could happen when resizing a window with fallback decorations. Fixes #2204 --- CONTRIBUTORS.md | 1 + README.md | 2 ++ src/wl_window.c | 3 +++ 3 files changed, 6 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 5f5c12f8..5d68bb77 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -168,6 +168,7 @@ video tutorials. - Pascal Muetschard - James Murphy - Julian Møller + - Nat - NateIsStalling - ndogxj - F. Nedelec diff --git a/README.md b/README.md index 948b3212..2d74ab8d 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - [Wayland] Bugfix: `GLFW_HOVERED` was true when the cursor was over any fallback window decoration + - [Wayland] Bugfix: Fallback decorations allowed resizing to invalid size + (#2204) - [X11] Bugfix: Termination would segfault if the IM had been destroyed - [X11] Bugfix: Any IM started after initialization would not be detected - [Linux] Bugfix: Joystick evdev fds remained open in forks (#2446) diff --git a/src/wl_window.c b/src/wl_window.c index ede4d659..a1f805cb 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -340,6 +340,9 @@ static void resizeFramebuffer(_GLFWwindow* window) static GLFWbool resizeWindow(_GLFWwindow* window, int width, int height) { + width = _glfw_max(width, 1); + height = _glfw_max(height, 1); + if (width == window->wl.width && height == window->wl.height) return GLFW_FALSE; From 690a15f92963b4ad2add09a91ccb2ee5b4085909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Feb 2024 19:45:59 +0100 Subject: [PATCH 089/137] Wayland: Implement GLFW_RESIZABLE for XDG toplevel This implements GLFW_RESIZABLE for all paths where we manage our own xdg_toplevel, namely XDG decorations and fallback decorations. Fixes #2203 --- README.md | 1 + src/wl_window.c | 167 ++++++++++++++++++++++-------------------------- 2 files changed, 79 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index 2d74ab8d..0988fa72 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ information on what to include when reporting a bug. would abort (#1649) - [Wayland] Added support for `glfwRequestWindowAttention` (#2287) - [Wayland] Added support for `glfwFocusWindow` + - [Wayland] Added support for `GLFW_RESIZABLE` (#2203) - [Wayland] Added support for fractional scaling of window contents - [Wayland] Added dynamic loading of all Wayland libraries - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/wl_window.c b/src/wl_window.c index a1f805cb..a965fc58 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -869,6 +869,50 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) return GLFW_TRUE; } +static void updateXdgSizeLimits(_GLFWwindow* window) +{ + int minwidth, minheight, maxwidth, maxheight; + + if (window->resizable) + { + if (window->minwidth == GLFW_DONT_CARE || window->minheight == GLFW_DONT_CARE) + minwidth = minheight = 0; + else + { + minwidth = window->minwidth; + minheight = window->minheight; + + if (window->wl.fallback.decorations) + { + minwidth += GLFW_BORDER_SIZE * 2; + minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; + } + } + + if (window->maxwidth == GLFW_DONT_CARE || window->maxheight == GLFW_DONT_CARE) + maxwidth = maxheight = 0; + else + { + maxwidth = window->maxwidth; + maxheight = window->maxheight; + + if (window->wl.fallback.decorations) + { + maxwidth += GLFW_BORDER_SIZE * 2; + maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; + } + } + } + else + { + minwidth = maxwidth = window->wl.width; + minheight = maxheight = window->wl.height; + } + + xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight); + xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight); +} + static GLFWbool createXdgShellObjects(_GLFWwindow* window) { window->wl.xdg.surface = xdg_wm_base_get_xdg_surface(_glfw.wl.wmBase, @@ -935,33 +979,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) createFallbackDecorations(window); } - if (window->minwidth != GLFW_DONT_CARE && window->minheight != GLFW_DONT_CARE) - { - int minwidth = window->minwidth; - int minheight = window->minheight; - - if (window->wl.fallback.decorations) - { - minwidth += GLFW_BORDER_SIZE * 2; - minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; - } - - xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight); - } - - if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE) - { - int maxwidth = window->maxwidth; - int maxheight = window->maxheight; - - if (window->wl.fallback.decorations) - { - maxwidth += GLFW_BORDER_SIZE * 2; - maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; - } - - xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight); - } + updateXdgSizeLimits(window); wl_surface_commit(window->wl.surface); wl_display_roundtrip(_glfw.wl.display); @@ -1437,37 +1455,38 @@ static void pointerHandleMotion(void* userData, if (window->wl.fallback.decorations) { - const char* cursorName = NULL; + const char* cursorName = "left_ptr"; - if (window->wl.fallback.focus == window->wl.fallback.top.surface) + if (window->resizable) { - if (ypos < GLFW_BORDER_SIZE) - cursorName = "n-resize"; - else - cursorName = "left_ptr"; - } - else if (window->wl.fallback.focus == window->wl.fallback.left.surface) - { - if (ypos < GLFW_BORDER_SIZE) - cursorName = "nw-resize"; - else - cursorName = "w-resize"; - } - else if (window->wl.fallback.focus == window->wl.fallback.right.surface) - { - if (ypos < GLFW_BORDER_SIZE) - cursorName = "ne-resize"; - else - cursorName = "e-resize"; - } - else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface) - { - if (xpos < GLFW_BORDER_SIZE) - cursorName = "sw-resize"; - else if (xpos > window->wl.width + GLFW_BORDER_SIZE) - cursorName = "se-resize"; - else - cursorName = "s-resize"; + if (window->wl.fallback.focus == window->wl.fallback.top.surface) + { + if (ypos < GLFW_BORDER_SIZE) + cursorName = "n-resize"; + } + else if (window->wl.fallback.focus == window->wl.fallback.left.surface) + { + if (ypos < GLFW_BORDER_SIZE) + cursorName = "nw-resize"; + else + cursorName = "w-resize"; + } + else if (window->wl.fallback.focus == window->wl.fallback.right.surface) + { + if (ypos < GLFW_BORDER_SIZE) + cursorName = "ne-resize"; + else + cursorName = "e-resize"; + } + else if (window->wl.fallback.focus == window->wl.fallback.bottom.surface) + { + if (xpos < GLFW_BORDER_SIZE) + cursorName = "sw-resize"; + else if (xpos > window->wl.width + GLFW_BORDER_SIZE) + cursorName = "se-resize"; + else + cursorName = "s-resize"; + } } if (_glfw.wl.cursorPreviousName != cursorName) @@ -2287,33 +2306,7 @@ void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, maxwidth, maxheight); } else if (window->wl.xdg.toplevel) - { - if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE) - minwidth = minheight = 0; - else - { - if (window->wl.fallback.decorations) - { - minwidth += GLFW_BORDER_SIZE * 2; - minheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; - } - } - - if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE) - maxwidth = maxheight = 0; - else - { - if (window->wl.fallback.decorations) - { - maxwidth += GLFW_BORDER_SIZE * 2; - maxheight += GLFW_CAPTION_HEIGHT + GLFW_BORDER_SIZE; - } - } - - 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); - } + updateXdgSizeLimits(window); } void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom) @@ -2581,12 +2574,8 @@ void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled) LIBDECOR_ACTION_RESIZE); } } - else - { - // TODO - _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED, - "Wayland: Window attribute setting not implemented yet"); - } + else if (window->wl.xdg.toplevel) + updateXdgSizeLimits(window); } void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled) From 14e653358bd46127931cf04aaba00d9f12cd03fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Feb 2024 20:55:28 +0100 Subject: [PATCH 090/137] Add support for XDG_SESSION_TYPE env variable Related to #2439 --- README.md | 1 + include/GLFW/glfw3.h | 7 +++++++ src/platform.c | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/README.md b/README.md index 0988fa72..cf8bf655 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,7 @@ information on what to include when reporting a bug. - Added `GLFW_BUILD_X11` CMake option for enabling X11 support (#1958) - Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type (#279,#1307,#1497,#1574,#1928) + - Added support for `XDG_SESSION_TYPE` environment variable - Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake variables exposing pkg-config dependencies (#1307) - Made joystick subsystem initialize at first use (#1284,#1646) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 6423d61f..c8ca3ffe 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2199,6 +2199,13 @@ typedef struct GLFWallocator * application locale according to the current environment if that category is * still "C". This is because the "C" locale breaks Unicode text input. * + * @remark __Wayland, X11:__ If the library was compiled with support for both + * Wayland and X11, and the @ref GLFW_PLATFORM init hint is set to + * `GLFW_ANY_PLATFORM`, the `XDG_SESSION_TYPE` environment variable affects + * which platform is picked. If the environment variable is not set, or is set + * to something other than `wayland` or `x11`, the regular detection mechanism + * will be used instead. + * * @thread_safety This function must only be called from the main thread. * * @sa @ref intro_init diff --git a/src/platform.c b/src/platform.c index e666ccd8..aea47bfb 100644 --- a/src/platform.c +++ b/src/platform.c @@ -27,6 +27,9 @@ #include "internal.h" +#include +#include + // These construct a string literal from individual numeric constants #define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r #define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r) @@ -80,6 +83,22 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) return GLFW_FALSE; } +#if defined(_GLFW_WAYLAND) && defined(_GLFW_X11) + if (desiredID == GLFW_ANY_PLATFORM) + { + const char* const session = getenv("XDG_SESSION_TYPE"); + if (session) + { + // Only follow XDG_SESSION_TYPE if it is set correctly and the + // environment looks plausble; otherwise fall back to detection + if (strcmp(session, "wayland") == 0 && getenv("WAYLAND_DISPLAY")) + desiredID = GLFW_PLATFORM_WAYLAND; + else if (strcmp(session, "x11") == 0 && getenv("DISPLAY")) + desiredID = GLFW_PLATFORM_X11; + } + } +#endif + if (desiredID == GLFW_ANY_PLATFORM) { // If there is exactly one platform available for auto-selection, let it emit the From f0ec791386b24bcea6210e37d9ad1c79b2722911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Feb 2024 11:59:51 +0100 Subject: [PATCH 091/137] X11: Cleanup The actual reported bug was fixed at some point during the refactoring of the Wayland backend. This is only a bit of tidying. Updating the cache before emitting events is always a nice thing to do. Closes #2046 --- CONTRIBUTORS.md | 1 + src/x11_window.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 5d68bb77..855df93e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -168,6 +168,7 @@ video tutorials. - Pascal Muetschard - James Murphy - Julian Møller + - Julius Häger - Nat - NateIsStalling - ndogxj diff --git a/src/x11_window.c b/src/x11_window.c index a94978cf..e0295465 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1488,6 +1488,9 @@ static void processEvent(XEvent *event) if (event->xconfigure.width != window->x11.width || event->xconfigure.height != window->x11.height) { + window->x11.width = event->xconfigure.width; + window->x11.height = event->xconfigure.height; + _glfwInputFramebufferSize(window, event->xconfigure.width, event->xconfigure.height); @@ -1495,9 +1498,6 @@ static void processEvent(XEvent *event) _glfwInputWindowSize(window, event->xconfigure.width, event->xconfigure.height); - - window->x11.width = event->xconfigure.width; - window->x11.height = event->xconfigure.height; } int xpos = event->xconfigure.x; @@ -1525,9 +1525,10 @@ static void processEvent(XEvent *event) if (xpos != window->x11.xpos || ypos != window->x11.ypos) { - _glfwInputWindowPos(window, xpos, ypos); window->x11.xpos = xpos; window->x11.ypos = ypos; + + _glfwInputWindowPos(window, xpos, ypos); } return; From a53ce7e8b8b7f3e98dc7587256afada9cc39bc6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Feb 2024 12:25:13 +0100 Subject: [PATCH 092/137] Null: Fix window/framebuffer size event order --- src/null_window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/null_window.c b/src/null_window.c index c2aafbad..8606106f 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -258,8 +258,8 @@ void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height) { window->null.width = width; window->null.height = height; - _glfwInputWindowSize(window, width, height); _glfwInputFramebufferSize(window, width, height); + _glfwInputWindowSize(window, width, height); } } From 64b4f0f30c60f11aee715214a9d8faef4372d946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Feb 2024 12:29:54 +0100 Subject: [PATCH 093/137] Null: Fix missing damage event --- src/null_window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/null_window.c b/src/null_window.c index 8606106f..1db08114 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -259,6 +259,7 @@ void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height) window->null.width = width; window->null.height = height; _glfwInputFramebufferSize(window, width, height); + _glfwInputWindowDamage(window); _glfwInputWindowSize(window, width, height); } } From bafece4cf7a0c34c9fb7b31096b770b3ec7a7669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Feb 2024 16:04:49 +0100 Subject: [PATCH 094/137] Update Wayland remarks for glfwCreateWindow The backend has improved somewhat and support among compositors for some protocols have improved to the point that they can be relied upon. --- include/GLFW/glfw3.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index c8ca3ffe..9268e4f3 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3198,6 +3198,15 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified * window size and position may be overridden by previously saved values. * + * @remark @wayland GLFW uses [libdecor][] where available to create its window + * decorations. This in turn uses server-side XDG decorations where available + * and provides high quality client-side decorations on compositors like GNOME. + * If both XDG decorations and libdecor are unavailable, GLFW falls back to + * a very simple set of window decorations that only support moving, resizing + * and the window manager's right-click menu. + * + * [libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor + * * @remark @x11 Some window managers will not respect the placement of * initially hidden windows. * @@ -3214,20 +3223,6 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to * override this. * - * @remark @wayland Compositors should implement the xdg-decoration protocol - * for GLFW to decorate the window properly. If this protocol isn't - * supported, or if the compositor prefers client-side decorations, a very - * simple fallback frame will be drawn using the wp_viewporter protocol. A - * compositor can still emit close, maximize or fullscreen events, using for - * instance a keybind mechanism. If neither of these protocols is supported, - * the window won't be decorated. - * - * @remark @wayland A full screen window will not attempt to change the mode, - * no matter what the requested size or refresh rate. - * - * @remark @wayland Screensaver inhibition requires the idle-inhibit protocol - * to be implemented in the user's compositor. - * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_creation From 95d464bb4b00c4a11683587591e3c90b3db9b0ed Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Wed, 7 Feb 2024 19:26:52 +0000 Subject: [PATCH 095/137] Add glfwGetWindowTitle This adds a function for querying the current title of a window. This currently returns a copy of the last title set via GLFW. Fixes #1448 Closes #1909 Closes #2482 --- CONTRIBUTORS.md | 1 + README.md | 1 + docs/news.md | 7 +++++++ docs/window.md | 9 +++++++++ include/GLFW/glfw3.h | 24 ++++++++++++++++++++++++ src/internal.h | 1 + src/window.c | 18 +++++++++++++++++- tests/window.c | 22 +++++++++++++++++++++- 8 files changed, 81 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 855df93e..19f60f2e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -15,6 +15,7 @@ video tutorials. - Keith Bauer - John Bartholomew - Coşku Baş + - Bayemite - Niklas Behrens - Andrew Belt - Nevyn Bengtsson diff --git a/README.md b/README.md index cf8bf655..476bd87a 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,7 @@ information on what to include when reporting a bug. - Added support for `XDG_SESSION_TYPE` environment variable - Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake variables exposing pkg-config dependencies (#1307) + - Added `glfwGetWindowTitle` function for GLFWwindow for querying window titles (#1448,#1909) - Made joystick subsystem initialize at first use (#1284,#1646) - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 diff --git a/docs/news.md b/docs/news.md index 7842ddf5..4f8bbbe5 100644 --- a/docs/news.md +++ b/docs/news.md @@ -41,6 +41,12 @@ to whatever window is behind it. This can also be changed after window creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib). +#### Ability to get a window's title {#features_34_get_window_title} + +GLFW now supports retrieving a window's title with the @ref glfwGetWindowTitle +function. + + #### Wayland libdecor decorations {#wayland_libdecor_34} GLFW now supports improved fallback window decorations via @@ -253,6 +259,7 @@ then GLFW will fail to initialize. - @ref glfwGetPlatform - @ref glfwPlatformSupported - @ref glfwInitVulkanLoader + - @ref glfwGetWindowTitle #### New types in version 3.4 {#types_34} diff --git a/docs/window.md b/docs/window.md index f4e153c3..bfd99bc8 100644 --- a/docs/window.md +++ b/docs/window.md @@ -919,6 +919,15 @@ If you are using C++11 or C11, you can use a UTF-8 string literal. glfwSetWindowTitle(window, u8"This is always a UTF-8 string"); ``` +The window title can be retrieved with @ref glfwGetWindowTitle. + +```c +const char* title = glfwGetWindowTitle(window); +``` + +The title returned is an internally managed copy of the title set +by @ref glfwCreateWindow or @ref glfwSetWindowTitle. It does not +include any additional text which may be appended by the platform. ### Window icon {#window_icon} diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 9268e4f3..3563ca62 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3305,6 +3305,30 @@ GLFWAPI int glfwWindowShouldClose(GLFWwindow* window); */ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); +/*! @brief Retrieves the title of the specified window. + * + * This function gets the window title, encoded as UTF-8, of the specified + * window. + * + * @param[in] window The window to query. + * @return A copy of the UTF-8 encoded window title, as set by glfwCreateWindow + * or glfwSetWindowTitle, or NULL if there is an error. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED + * + * @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 + * glfwSetWindowTitle, or until the library is terminated. + * + * @thread_safety This function must only be called from the main thread. + * + * @sa @ref window_title + * @sa @ref glfwSetWindowTitle + * + * @ingroup window + */ +GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window); + /*! @brief Sets the title of the specified window. * * This function sets the window title, encoded as UTF-8, of the specified diff --git a/src/internal.h b/src/internal.h index c6c856f1..24750adc 100644 --- a/src/internal.h +++ b/src/internal.h @@ -532,6 +532,7 @@ struct _GLFWwindow GLFWvidmode videoMode; _GLFWmonitor* monitor; _GLFWcursor* cursor; + char* title; int minwidth, minheight; int maxwidth, maxheight; diff --git a/src/window.c b/src/window.c index 3b8d706e..abd54dc2 100644 --- a/src/window.c +++ b/src/window.c @@ -242,6 +242,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->maxheight = GLFW_DONT_CARE; window->numer = GLFW_DONT_CARE; window->denom = GLFW_DONT_CARE; + window->title = _glfw_strdup(title); if (!_glfw.platform.createWindow(window, &wndconfig, &ctxconfig, &fbconfig)) { @@ -493,7 +494,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle) *prev = window->next; } - + _glfw_free(window->title); _glfw_free(window); } @@ -515,6 +516,16 @@ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value) window->shouldClose = value; } +GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* handle) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + + return window->title; +} + GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title) { _GLFWwindow* window = (_GLFWwindow*) handle; @@ -522,7 +533,12 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title) assert(title != NULL); _GLFW_REQUIRE_INIT(); + + char* prev = window->title; + window->title = _glfw_strdup(title); + _glfw.platform.setWindowTitle(window, title); + _glfw_free(prev); } GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle, diff --git a/tests/window.c b/tests/window.c index 94c4f172..00d49b4b 100644 --- a/tests/window.c +++ b/tests/window.c @@ -62,6 +62,7 @@ int main(int argc, char** argv) char min_width_buffer[12] = "", min_height_buffer[12] = ""; char max_width_buffer[12] = "", max_height_buffer[12] = ""; int may_close = true; + char window_title[64] = ""; if (!glfwInit()) exit(EXIT_FAILURE); @@ -71,7 +72,7 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); - GLFWwindow* window = glfwCreateWindow(600, 630, "Window Features", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(600, 660, "Window Features", NULL, NULL); if (!window) { glfwTerminate(); @@ -109,6 +110,11 @@ int main(int argc, char** argv) nk_glfw3_font_stash_begin(&atlas); nk_glfw3_font_stash_end(); + // test setting title with result from glfwGetWindowTitle + glfwSetWindowTitle(window, glfwGetWindowTitle(window)); + + strncpy( window_title, glfwGetWindowTitle(window), sizeof(window_title)); + while (!(may_close && glfwWindowShouldClose(window))) { int width, height; @@ -188,11 +194,25 @@ int main(int argc, char** argv) nk_label(nk, "Press Enter in a text field to set value", NK_TEXT_CENTERED); + + nk_flags events; const nk_flags flags = NK_EDIT_FIELD | NK_EDIT_SIG_ENTER | NK_EDIT_GOTO_END_ON_ACTIVATE; + nk_layout_row_dynamic(nk, 30, 2); + nk_label(nk, "Window Title:", NK_TEXT_LEFT); + + events = nk_edit_string_zero_terminated( nk, flags, window_title, sizeof(window_title), NULL ); + + if (events & NK_EDIT_COMMITED) + { + glfwSetWindowTitle(window, window_title); + // we do not need to call glfwGetWindowTitle as we already store the title, but using it here for testing purposes + strncpy( window_title, glfwGetWindowTitle(window), sizeof(window_title)); + } + if (position_supported) { int xpos, ypos; From af5d2505539e1bce9f97b553f92cca6161a45552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Feb 2024 15:30:44 +0100 Subject: [PATCH 096/137] Wayland: Remove separate window title copy --- src/wl_platform.h | 1 - src/wl_window.c | 12 ++---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index 76d7c9cb..b3478df1 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -387,7 +387,6 @@ typedef struct _GLFWwindowWayland _GLFWcursor* currentCursor; double cursorPosX, cursorPosY; - char* title; char* appId; // We need to track the monitors the window spans on to calculate the diff --git a/src/wl_window.c b/src/wl_window.c index a965fc58..5b491ffb 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -822,8 +822,7 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) if (strlen(window->wl.appId)) libdecor_frame_set_app_id(window->wl.libdecor.frame, window->wl.appId); - if (strlen(window->wl.title)) - libdecor_frame_set_title(window->wl.libdecor.frame, window->wl.title); + libdecor_frame_set_title(window->wl.libdecor.frame, window->title); if (window->minwidth != GLFW_DONT_CARE && window->minheight != GLFW_DONT_CARE) @@ -939,8 +938,7 @@ static GLFWbool createXdgShellObjects(_GLFWwindow* window) if (window->wl.appId) xdg_toplevel_set_app_id(window->wl.xdg.toplevel, window->wl.appId); - if (window->wl.title) - xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title); + xdg_toplevel_set_title(window->wl.xdg.toplevel, window->title); if (window->monitor) { @@ -1040,7 +1038,6 @@ static GLFWbool createNativeSurface(_GLFWwindow* window, window->wl.height = wndconfig->height; window->wl.fbWidth = wndconfig->width; window->wl.fbHeight = wndconfig->height; - window->wl.title = _glfw_strdup(wndconfig->title); window->wl.appId = _glfw_strdup(wndconfig->wl.appId); window->wl.bufferScale = 1; @@ -2215,17 +2212,12 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) if (window->wl.surface) wl_surface_destroy(window->wl.surface); - _glfw_free(window->wl.title); _glfw_free(window->wl.appId); _glfw_free(window->wl.outputScales); } void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title) { - char* copy = _glfw_strdup(title); - _glfw_free(window->wl.title); - window->wl.title = copy; - if (window->wl.libdecor.frame) libdecor_frame_set_title(window->wl.libdecor.frame, title); else if (window->wl.xdg.toplevel) From 1ce41b358b92a34aceb642ce540f01cdb980f755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Feb 2024 16:49:15 +0100 Subject: [PATCH 097/137] Null: Remove unused struct member --- src/null_platform.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/null_platform.h b/src/null_platform.h index fb9374b4..f9706acc 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -164,7 +164,6 @@ typedef struct _GLFWwindowNull int ypos; int width; int height; - char* title; GLFWbool visible; GLFWbool iconified; GLFWbool maximized; From c8372cda08cd8b89d2f578d9b3126cd0cbe8a54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Feb 2024 13:45:22 +0100 Subject: [PATCH 098/137] Documentation work --- README.md | 2 +- docs/news.md | 6 ++++-- docs/window.md | 8 ++------ include/GLFW/glfw3.h | 23 ++++++++++++++++------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 476bd87a..c9499fd9 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ information on what to include when reporting a bug. - Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947) - Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and `GLFWdeallocatefun` types (#544,#1628,#1947) + - Added `glfwGetWindowTitle` function for querying window title (#1448,#1909,#2482) - Added `glfwInitVulkanLoader` for using a non-default Vulkan loader (#1374,#1890) - Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`, `GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427) @@ -167,7 +168,6 @@ information on what to include when reporting a bug. - Added support for `XDG_SESSION_TYPE` environment variable - Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake variables exposing pkg-config dependencies (#1307) - - Added `glfwGetWindowTitle` function for GLFWwindow for querying window titles (#1448,#1909) - Made joystick subsystem initialize at first use (#1284,#1646) - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 diff --git a/docs/news.md b/docs/news.md index 4f8bbbe5..3d820be1 100644 --- a/docs/news.md +++ b/docs/news.md @@ -41,11 +41,13 @@ to whatever window is behind it. This can also be changed after window creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib). -#### Ability to get a window's title {#features_34_get_window_title} +#### Ability to get window title {#features_34_window_title} -GLFW now supports retrieving a window's title with the @ref glfwGetWindowTitle +GLFW now supports querying the title of a window with the @ref glfwGetWindowTitle function. +For more information see @ref window_title. + #### Wayland libdecor decorations {#wayland_libdecor_34} diff --git a/docs/window.md b/docs/window.md index bfd99bc8..3d6c6805 100644 --- a/docs/window.md +++ b/docs/window.md @@ -897,7 +897,7 @@ glfwGetWindowPos(window, &xpos, &ypos); All GLFW windows have a title, although undecorated or full screen windows may not display it or only display it in a task bar or similar interface. You can -set a UTF-8 encoded window title with @ref glfwSetWindowTitle. +set a new UTF-8 encoded window title with @ref glfwSetWindowTitle. ```c glfwSetWindowTitle(window, "My Window"); @@ -919,16 +919,12 @@ If you are using C++11 or C11, you can use a UTF-8 string literal. glfwSetWindowTitle(window, u8"This is always a UTF-8 string"); ``` -The window title can be retrieved with @ref glfwGetWindowTitle. +The current window title can be queried with @ref glfwGetWindowTitle. ```c const char* title = glfwGetWindowTitle(window); ``` -The title returned is an internally managed copy of the title set -by @ref glfwCreateWindow or @ref glfwSetWindowTitle. It does not -include any additional text which may be appended by the platform. - ### Window icon {#window_icon} Decorated windows have icons on some platforms. You can set this icon by diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 3563ca62..da3c3c57 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3305,26 +3305,34 @@ GLFWAPI int glfwWindowShouldClose(GLFWwindow* window); */ GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); -/*! @brief Retrieves the title of the specified window. +/*! @brief Returns the title of the specified window. * - * This function gets the window title, encoded as UTF-8, of the specified - * window. + * This function returns the window title, encoded as UTF-8, of the specified + * window. This is the title set previously by @ref glfwCreateWindow + * or @ref glfwSetWindowTitle. * * @param[in] window The window to query. - * @return A copy of the UTF-8 encoded window title, as set by glfwCreateWindow - * or glfwSetWindowTitle, or NULL if there is an error. + * @return The UTF-8 encoded window title, or `NULL` if an + * [error](@ref error_handling) occurred. * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. + * + * @remark The returned title is currently a copy of the title last set by @ref + * glfwCreateWindow or @ref glfwSetWindowTitle. It does not include any + * additional text which may be appended by the platform or another program. * * @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 - * glfwSetWindowTitle, or until the library is terminated. + * glfwGetWindowTitle or @ref glfwSetWindowTitle, or until the library is + * terminated. * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_title * @sa @ref glfwSetWindowTitle * + * @since Added in version 3.4. + * * @ingroup window */ GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window); @@ -3346,6 +3354,7 @@ GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window); * @thread_safety This function must only be called from the main thread. * * @sa @ref window_title + * @sa @ref glfwGetWindowTitle * * @since Added in version 1.0. * @glfw3 Added window handle parameter. From 7bdcdf435aae8b471cc3d230bf7255c2e7f703d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 16 Feb 2024 13:57:18 +0100 Subject: [PATCH 099/137] Cleanup --- src/window.c | 1 + tests/window.c | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/window.c b/src/window.c index abd54dc2..1463d169 100644 --- a/src/window.c +++ b/src/window.c @@ -494,6 +494,7 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle) *prev = window->next; } + _glfw_free(window->title); _glfw_free(window); } diff --git a/tests/window.c b/tests/window.c index 00d49b4b..c81bf024 100644 --- a/tests/window.c +++ b/tests/window.c @@ -110,10 +110,7 @@ int main(int argc, char** argv) nk_glfw3_font_stash_begin(&atlas); nk_glfw3_font_stash_end(); - // test setting title with result from glfwGetWindowTitle - glfwSetWindowTitle(window, glfwGetWindowTitle(window)); - - strncpy( window_title, glfwGetWindowTitle(window), sizeof(window_title)); + strncpy(window_title, glfwGetWindowTitle(window), sizeof(window_title)); while (!(may_close && glfwWindowShouldClose(window))) { @@ -194,24 +191,20 @@ int main(int argc, char** argv) nk_label(nk, "Press Enter in a text field to set value", NK_TEXT_CENTERED); - - nk_flags events; const nk_flags flags = NK_EDIT_FIELD | NK_EDIT_SIG_ENTER | NK_EDIT_GOTO_END_ON_ACTIVATE; - nk_layout_row_dynamic(nk, 30, 2); - nk_label(nk, "Window Title:", NK_TEXT_LEFT); - - events = nk_edit_string_zero_terminated( nk, flags, window_title, sizeof(window_title), NULL ); - + nk_layout_row_begin(nk, NK_DYNAMIC, 30, 2); + nk_layout_row_push(nk, 1.f / 3.f); + nk_label(nk, "Title", NK_TEXT_LEFT); + nk_layout_row_push(nk, 2.f / 3.f); + events = nk_edit_string_zero_terminated(nk, flags, window_title, + sizeof(window_title), NULL); if (events & NK_EDIT_COMMITED) - { glfwSetWindowTitle(window, window_title); - // we do not need to call glfwGetWindowTitle as we already store the title, but using it here for testing purposes - strncpy( window_title, glfwGetWindowTitle(window), sizeof(window_title)); - } + nk_layout_row_end(nk); if (position_supported) { From 42afd127a9ff03c397ecbca51c22f74e92c6180f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Feb 2024 15:23:23 +0100 Subject: [PATCH 100/137] Documentation work --- docs/news.md | 62 +++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/docs/news.md b/docs/news.md index 3d820be1..823c0d6e 100644 --- a/docs/news.md +++ b/docs/news.md @@ -15,7 +15,7 @@ selected platform can be queried with @ref glfwGetPlatform. You can check if support for a given platform is compiled in with @ref glfwPlatformSupported. -#### More standard cursors {#standard_cursors_34} +#### More standard cursor shapes {#standard_cursors_34} 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 @@ -49,32 +49,6 @@ function. For more information see @ref window_title. -#### Wayland libdecor decorations {#wayland_libdecor_34} - -GLFW now supports improved fallback window decorations via -[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor). - -Support for libdecor can be toggled before GLFW is initialized with the -[GLFW_WAYLAND_LIBDECOR](@ref GLFW_WAYLAND_LIBDECOR_hint) init hint. It is -enabled by default. - - -#### Wayland app_id specification {#wayland_app_id_34} - -GLFW now supports specifying the app_id for a Wayland window using the -[GLFW_WAYLAND_APP_ID](@ref GLFW_WAYLAND_APP_ID_hint) window hint string. - - -#### Support for ANGLE rendering backend selection {#features_34_angle_backend} - -GLFW now provides the -[GLFW_ANGLE_PLATFORM_TYPE](@ref GLFW_ANGLE_PLATFORM_TYPE_hint) init hint for -requesting a specific rendering backend when using [ANGLE][] to create OpenGL ES -contexts. - -[ANGLE]: https://chromium.googlesource.com/angle/angle/ - - #### Captured cursor mode {#captured_cursor_34} GLFW now supports confining the cursor to the window content area with the @ref @@ -83,7 +57,7 @@ GLFW_CURSOR_CAPTURED cursor mode. For more information see @ref cursor_mode. -#### Support for custom memory allocator {#features_34_init_allocator} +#### Support for custom heap memory allocator {#features_34_init_allocator} GLFW now supports plugging a custom memory allocator at initialization with @ref glfwInitAllocator. The allocator is a struct of type @ref GLFWallocator with @@ -106,16 +80,18 @@ This was already possible on macOS via the hint. This hint is now another name for [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint). -For more information, see @ref window_scale. +For more information see @ref window_scale. -#### Window hints for initial position {#features_34_position_hint} +#### Window hints for initial window position {#features_34_position_hint} GLFW now provides the @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints for specifying the initial position of the window. This removes the need to create a hidden window, move it and then show it. The default value of these hints is `GLFW_ANY_POSITION`, which selects the previous behavior. +For more information see @ref window_pos. + #### Support for keyboard access to Windows window menu {#features_34_win32_keymenu} @@ -133,6 +109,32 @@ hint for applying the show command in the program's `STARTUPINFO` when showing t for the first time. This may be useful for the main window of a windowed-mode tool. +#### Wayland libdecor decorations {#wayland_libdecor_34} + +GLFW now supports improved fallback window decorations via +[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor). + +Support for libdecor can be toggled before GLFW is initialized with the +[GLFW_WAYLAND_LIBDECOR](@ref GLFW_WAYLAND_LIBDECOR_hint) init hint. It is +enabled by default. + + +#### Window hint for Wayland app_id {#wayland_app_id_34} + +GLFW now supports specifying the app_id for a Wayland window using the +[GLFW_WAYLAND_APP_ID](@ref GLFW_WAYLAND_APP_ID_hint) window hint string. + + +#### Support for ANGLE rendering backend selection {#features_34_angle_backend} + +GLFW now provides the +[GLFW_ANGLE_PLATFORM_TYPE](@ref GLFW_ANGLE_PLATFORM_TYPE_hint) init hint for +requesting a specific rendering backend when using [ANGLE][] to create OpenGL ES +contexts. + +[ANGLE]: https://chromium.googlesource.com/angle/angle/ + + ### Caveats for version 3.4 {#caveats} #### Multiple sets of native access functions {#native_34} From dbf7cfc4dc69517cd8618ca01c49053aa9373f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Feb 2024 17:00:26 +0100 Subject: [PATCH 101/137] Update credit Related to #2204 --- CONTRIBUTORS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 19f60f2e..5d0b601e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -170,7 +170,7 @@ video tutorials. - James Murphy - Julian Møller - Julius Häger - - Nat + - Nat! - NateIsStalling - ndogxj - F. Nedelec From 65102e20059853bb57c3e8eff91c756b22c2a395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BClsmann?= Date: Sun, 30 Jan 2022 00:36:32 +0100 Subject: [PATCH 102/137] Prefer Wayland over X11 When GLFW_ANY_PLATFORM is used (which is the default), X11 would be selected on a Wayland system with XWayland and where XDG_SESSION_TYPE was not set. Closes #2035 --- README.md | 1 + src/platform.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9499fd9..b3e784e9 100644 --- a/README.md +++ b/README.md @@ -358,6 +358,7 @@ information on what to include when reporting a bug. - [Wayland] Disabled alpha channel for opaque windows on systems lacking `EGL_EXT_present_opaque` (#1895) - [Wayland] Removed support for `wl_shell` (#1443) + - [Wayland] Prefer Wayland over X11 if both are available (#2035) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704) - [Wayland] Bugfix: Retrieving partial framebuffer size would segfault diff --git a/src/platform.c b/src/platform.c index aea47bfb..af1b0f44 100644 --- a/src/platform.c +++ b/src/platform.c @@ -50,12 +50,12 @@ static const struct #if defined(_GLFW_COCOA) { GLFW_PLATFORM_COCOA, _glfwConnectCocoa }, #endif -#if defined(_GLFW_X11) - { GLFW_PLATFORM_X11, _glfwConnectX11 }, -#endif #if defined(_GLFW_WAYLAND) { GLFW_PLATFORM_WAYLAND, _glfwConnectWayland }, #endif +#if defined(_GLFW_X11) + { GLFW_PLATFORM_X11, _glfwConnectX11 }, +#endif }; GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform) From 559bd3adb90f6b913db3d5b83f5f719bf4dd6fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 19 Feb 2024 14:44:02 +0100 Subject: [PATCH 103/137] Add credit Related to #2035 --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 5d0b601e..d2706831 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -101,6 +101,7 @@ video tutorials. - Warren Hu - Charles Huber - Brent Huisman + - Florian Hülsmann - illustris - InKryption - IntellectualKitty From 0bb605cd797e4d63709495f4074ec59362064ab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 19 Feb 2024 15:06:59 +0100 Subject: [PATCH 104/137] Wayland related documentation work --- README.md | 4 ++-- docs/compile.md | 2 +- docs/intro.md | 26 +++++++++++++------------- docs/window.md | 17 +++++++++-------- include/GLFW/glfw3.h | 34 +++++++++++++--------------------- 5 files changed, 38 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index b3e784e9..95ac99c4 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 are supported. +Linux both Wayland and X11 are supported. GLFW is licensed under the [zlib/libpng license](https://www.glfw.org/license.html). @@ -170,6 +170,7 @@ information on what to include when reporting a bug. variables exposing pkg-config dependencies (#1307) - Made joystick subsystem initialize at first use (#1284,#1646) - Made `GLFW_DOUBLEBUFFER` a read-only window attribute + - Made Wayland the preferred platform over X11 if both are available (#2035) - Updated the minimum required CMake version to 3.1 - Updated gamepad mappings from upstream - Renamed `GLFW_USE_WAYLAND` CMake option to `GLFW_BUILD_WAYLAND` (#1958) @@ -358,7 +359,6 @@ information on what to include when reporting a bug. - [Wayland] Disabled alpha channel for opaque windows on systems lacking `EGL_EXT_present_opaque` (#1895) - [Wayland] Removed support for `wl_shell` (#1443) - - [Wayland] Prefer Wayland over X11 if both are available (#2035) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704) - [Wayland] Bugfix: Retrieving partial framebuffer size would segfault diff --git a/docs/compile.md b/docs/compile.md index 14c8bc10..f8385fef 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -350,8 +350,8 @@ clipboard. The options are: - @b _GLFW_COCOA to use the Cocoa frameworks - @b _GLFW_WIN32 to use the Win32 API + - @b _GLFW_WAYLAND to use the Wayland protocol - @b _GLFW_X11 to use the X Window System - - @b _GLFW_WAYLAND to use the Wayland API (incomplete) The @b _GLFW_WAYLAND and @b _GLFW_X11 macros may be combined and produces a library that attempts to detect the appropriate platform at initialization. diff --git a/docs/intro.md b/docs/intro.md index 54e6e5bb..0610202f 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -92,7 +92,7 @@ Setting these hints requires no platform specific headers or functions. @anchor GLFW_PLATFORM __GLFW_PLATFORM__ specifies the platform to use for windowing and input. Possible values are `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, -`GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_X11`, `GLFW_PLATFORM_WAYLAND` and +`GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL`. The default value is `GLFW_ANY_PLATFORM`, which will choose any platform the library includes support for except for the Null backend. @@ -134,15 +134,6 @@ a nib or manually by GLFW. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This is ignored on other platforms. -#### X11 specific init hints {#init_hints_x11} - -@anchor GLFW_X11_XCB_VULKAN_SURFACE_hint -__GLFW_X11_XCB_VULKAN_SURFACE__ specifies whether to prefer the -`VK_KHR_xcb_surface` extension for creating Vulkan surfaces, or whether to use -the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and -`GLFW_FALSE`. This is ignored on other platforms. - - #### Wayland specific init hints {#init_hints_wayland} @anchor GLFW_WAYLAND_LIBDECOR_hint @@ -153,23 +144,32 @@ and `GLFW_WAYLAND_DISABLE_LIBDECOR`. This is ignored on other platforms. [libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor +#### X11 specific init hints {#init_hints_x11} + +@anchor GLFW_X11_XCB_VULKAN_SURFACE_hint +__GLFW_X11_XCB_VULKAN_SURFACE__ specifies whether to prefer the +`VK_KHR_xcb_surface` extension for creating Vulkan surfaces, or whether to use +the `VK_KHR_xlib_surface` extension. Possible values are `GLFW_TRUE` and +`GLFW_FALSE`. This is ignored on other platforms. + + #### Supported and default values {#init_hints_values} Initialization hint | Default value | Supported values -------------------------------- | ------------------------------- | ---------------- -@ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_X11`, `GLFW_PLATFORM_WAYLAND` or `GLFW_PLATFORM_NULL` +@ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL` @ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL` @ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` -@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` @ref GLFW_WAYLAND_LIBDECOR | `GLFW_WAYLAND_PREFER_LIBDECOR` | `GLFW_WAYLAND_PREFER_LIBDECOR` or `GLFW_WAYLAND_DISABLE_LIBDECOR` +@ref GLFW_X11_XCB_VULKAN_SURFACE | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` ### Runtime platform selection {#platform} GLFW can be compiled for more than one platform (window system) at once. This lets -a single library binary support both X11 and Wayland on Linux and other Unix-like systems. +a single library binary support both Wayland and X11 on Linux and other Unix-like systems. You can control platform selection via the @ref GLFW_PLATFORM initialization hint. By default, this is set to @ref GLFW_ANY_PLATFORM, which will look for supported window diff --git a/docs/window.md b/docs/window.md index 3d6c6805..371baa56 100644 --- a/docs/window.md +++ b/docs/window.md @@ -511,6 +511,14 @@ should also declare this in its `Info.plist` by setting the `NSSupportsAutomaticGraphicsSwitching` key to `true`. +#### Wayland specific window hints {#window_hints_wayland} + +@anchor GLFW_WAYLAND_APP_ID_hint +__GLFW_WAYLAND_APP_ID__ specifies the Wayland app_id for a window, used +by window managers to identify types of windows. This is set with +@ref glfwWindowHintString. + + #### X11 specific window hints {#window_hints_x11} @anchor GLFW_X11_CLASS_NAME_hint @@ -520,13 +528,6 @@ ASCII encoded class and instance parts of the ICCCM `WM_CLASS` window property. hints need to be set to something other than an empty string for them to take effect. These are set with @ref glfwWindowHintString. -#### Wayland specific window hints {#window_hints_wayland} - -@anchor GLFW_WAYLAND_APP_ID_hint -__GLFW_WAYLAND_APP_ID__ specifies the Wayland app_id for a window, used -by window managers to identify types of windows. This is set with -@ref glfwWindowHintString. - #### Supported and default values {#window_hints_values} @@ -576,9 +577,9 @@ GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GL GLFW_WIN32_SHOWDEFAULT | `GLFW_FALSE` | `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` +GLFW_WAYLAND_APP_ID | `""` | An ASCII encoded Wayland `app_id` name GLFW_X11_CLASS_NAME | `""` | An ASCII encoded `WM_CLASS` class name GLFW_X11_INSTANCE_NAME | `""` | An ASCII encoded `WM_CLASS` instance name -GLFW_WAYLAND_APP_ID | `""` | An ASCII encoded Wayland `app_id` name ## Window event processing {#window_events} diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index da3c3c57..9c55ac9d 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1230,11 +1230,11 @@ extern "C" { * @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. + * + * @note @x11 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. @@ -1245,11 +1245,11 @@ extern "C" { * @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. + * + * @note @x11 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. @@ -1263,11 +1263,11 @@ extern "C" { * 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. + * + * @note @x11 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. @@ -2195,10 +2195,6 @@ typedef struct GLFWallocator * 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. - * * @remark __Wayland, X11:__ If the library was compiled with support for both * Wayland and X11, and the @ref GLFW_PLATFORM init hint is set to * `GLFW_ANY_PLATFORM`, the `XDG_SESSION_TYPE` environment variable affects @@ -2206,6 +2202,10 @@ typedef struct GLFWallocator * to something other than `wayland` or `x11`, the regular detection mechanism * will be used instead. * + * @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 @@ -3620,9 +3620,6 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland A full screen window will not attempt to change the mode, - * no matter what the requested size. - * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_size @@ -4063,9 +4060,6 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); * @remark @wayland The desired window position is ignored, as there is no way * for an application to set this property. * - * @remark @wayland Setting the window to full screen will not attempt to - * change the mode, no matter what the requested size or refresh rate. - * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_monitor @@ -5447,8 +5441,6 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun ca * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @wayland File drop is currently unimplemented. - * * @thread_safety This function must only be called from the main thread. * * @sa @ref path_drop From 1fb7f0e1205a44b69983ddf38079fd1d04dc49b7 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Tue, 20 Feb 2024 13:20:30 +0000 Subject: [PATCH 105/137] Cocoa: Added glfwGetCocoaView native access function Resolves #2235 Co-authored-by: mightgoyardstill --- CONTRIBUTORS.md | 1 + README.md | 1 + docs/news.md | 6 ++++++ include/GLFW/glfw3native.h | 17 +++++++++++++++++ src/cocoa_window.m | 15 +++++++++++++++ 5 files changed, 40 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d2706831..26a2936a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -154,6 +154,7 @@ video tutorials. - Jonathan Mercier - Marcel Metz - Liam Middlebrook + - mightgoyardstill - Ave Milia - Icyllis Milica - Jonathan Miller diff --git a/README.md b/README.md index 95ac99c4..787560a6 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,7 @@ information on what to include when reporting a bug. - [Win32] Added a version info resource to the GLFW DLL - [Win32] Made hidden helper window use its own window class - [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user + - [Cocoa] Added `glfwGetCocoaView` native access function (#2235) - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread would abort (#1649) diff --git a/docs/news.md b/docs/news.md index 823c0d6e..2eefc1b9 100644 --- a/docs/news.md +++ b/docs/news.md @@ -7,6 +7,12 @@ ### New features in version 3.4 {#features_34} +#### Cocoa NSView native access function {#native_cocoa_nsview_34} + +GLFW now provides the @ref glfwGetCocoaView native access function +for returning the Cocoa NSView. + + #### Runtime platform selection {#runtime_platform_34} GLFW now supports being compiled for multiple backends and selecting between diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 46072920..92f0d324 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -286,6 +286,23 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); * @ingroup native */ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window); + +/*! @brief Returns the `NSView` of the specified window. + * + * @return The `NSView` of the specified window, or `nil` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_PLATFORM_UNAVAILABLE. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @since Added in version 3.4. + * + * @ingroup native + */ +GLFWAPI id glfwGetCocoaView(GLFWwindow* window); #endif #if defined(GLFW_EXPOSE_NATIVE_NSGL) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 7e90cf99..96b6ca61 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -2053,5 +2053,20 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) return window->ns.object; } +GLFWAPI id glfwGetCocoaView(GLFWwindow* handle) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(nil); + + if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, + "Cocoa: Platform not initialized"); + return nil; + } + + return window->ns.view; +} + #endif // _GLFW_COCOA From f6360eadee2f1cb21208477ebe65cee89ffca35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Feb 2024 13:04:57 +0100 Subject: [PATCH 106/137] NSGL: Fix missing check for OpenGL profile macOS only provides the core profile for OpenGL 3.2 and later. --- README.md | 2 ++ src/nsgl_context.m | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 787560a6..b7ea493a 100644 --- a/README.md +++ b/README.md @@ -201,6 +201,8 @@ information on what to include when reporting a bug. - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) - [NSGL] Removed enforcement of forward-compatible flag for core contexts + - [NSGL] Bugfix: A core profile OpenGL context was returned if 3.2+ + compatibility profile was requested - [EGL] Added platform selection via the `EGL_EXT_platform_base` extension (#442) - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension diff --git a/src/nsgl_context.m b/src/nsgl_context.m index d19622c6..0b58e20a 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -175,6 +175,13 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, } } + if (ctxconfig->major >= 3 && ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE) + { + _glfwInputError(GLFW_VERSION_UNAVAILABLE, + "NSGL: The compatibility profile is not available on macOS"); + return GLFW_FALSE; + } + // Context robustness modes (GL_KHR_robustness) are not yet supported by // macOS but are not a hard constraint, so ignore and continue From 8f2f766f0d2ed476c03a2ae02e48ac41a9602b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Feb 2024 16:26:01 +0100 Subject: [PATCH 107/137] NSGL: ANGLE exists --- src/nsgl_context.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 0b58e20a..daa8367a 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -161,7 +161,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, if (ctxconfig->client == GLFW_OPENGL_ES_API) { _glfwInputError(GLFW_API_UNAVAILABLE, - "NSGL: OpenGL ES is not available on macOS"); + "NSGL: OpenGL ES is not available via NSGL"); return GLFW_FALSE; } From e28397bda08e75ba0aed67cbbf28f9c2701d5013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Feb 2024 12:50:59 +0100 Subject: [PATCH 108/137] Cocoa: Fix glfwGetCocoaWindow error return value --- 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 96b6ca61..0dcf0a38 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -2047,7 +2047,7 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) { _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Cocoa: Platform not initialized"); - return NULL; + return nil; } return window->ns.object; From 961e45bded3fcee8dffbbcd0e4bc1b1c096a3e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Feb 2024 13:21:21 +0100 Subject: [PATCH 109/137] Include declarations from native access header --- src/internal.h | 3 +++ src/platform.h | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/internal.h b/src/internal.h index 24750adc..0d528875 100644 --- a/src/internal.h +++ b/src/internal.h @@ -324,6 +324,9 @@ typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const c #include "platform.h" +#define GLFW_NATIVE_INCLUDE_NONE +#include "../include/GLFW/glfw3native.h" + // Checks for whether the library has been initialized #define _GLFW_REQUIRE_INIT() \ if (!_glfw.initialized) \ diff --git a/src/platform.h b/src/platform.h index 4e924a69..75652dcc 100644 --- a/src/platform.h +++ b/src/platform.h @@ -38,9 +38,13 @@ #endif #include "null_platform.h" +#define GLFW_EXPOSE_NATIVE_EGL +#define GLFW_EXPOSE_NATIVE_OSMESA #if defined(_GLFW_WIN32) #include "win32_platform.h" + #define GLFW_EXPOSE_NATIVE_WIN32 + #define GLFW_EXPOSE_NATIVE_WGL #else #define GLFW_WIN32_WINDOW_STATE #define GLFW_WIN32_MONITOR_STATE @@ -52,6 +56,8 @@ #if defined(_GLFW_COCOA) #include "cocoa_platform.h" + #define GLFW_EXPOSE_NATIVE_COCOA + #define GLFW_EXPOSE_NATIVE_NSGL #else #define GLFW_COCOA_WINDOW_STATE #define GLFW_COCOA_MONITOR_STATE @@ -63,6 +69,7 @@ #if defined(_GLFW_WAYLAND) #include "wl_platform.h" + #define GLFW_EXPOSE_NATIVE_WAYLAND #else #define GLFW_WAYLAND_WINDOW_STATE #define GLFW_WAYLAND_MONITOR_STATE @@ -72,6 +79,8 @@ #if defined(_GLFW_X11) #include "x11_platform.h" + #define GLFW_EXPOSE_NATIVE_X11 + #define GLFW_EXPOSE_NATIVE_GLX #else #define GLFW_X11_WINDOW_STATE #define GLFW_X11_MONITOR_STATE From f6f7ee22843ac1d6e7e7872ca71d30431fbaeb0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Feb 2024 17:38:54 +0100 Subject: [PATCH 110/137] Add new symbol to list --- docs/news.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/news.md b/docs/news.md index 2eefc1b9..e68464f6 100644 --- a/docs/news.md +++ b/docs/news.md @@ -270,6 +270,7 @@ then GLFW will fail to initialize. - @ref glfwPlatformSupported - @ref glfwInitVulkanLoader - @ref glfwGetWindowTitle + - @ref glfwGetCocoaView #### New types in version 3.4 {#types_34} From b864e4baeb590465700744a68d083fe0ebce5d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Feb 2024 19:23:52 +0100 Subject: [PATCH 111/137] Improved build guide slightly --- docs/build.md | 112 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 95 insertions(+), 17 deletions(-) diff --git a/docs/build.md b/docs/build.md index 6a5b4a0f..d00d676e 100644 --- a/docs/build.md +++ b/docs/build.md @@ -161,20 +161,95 @@ Linkers][linker_guide] by David Drysdale. [linker_guide]: https://www.lurklurk.org/linkers/linkers.html -### With MinGW or Visual C++ on Windows {#build_link_win32} +### With Visual C++ and GLFW binaries {#build_link_win32} -The static version of the GLFW library is named `glfw3`. When using this -version, it is also necessary to link with some libraries that GLFW uses. +If you are using a downloaded [binary +archive](https://www.glfw.org/download.html), first make sure you have the +archive matching the architecture you are building for (32-bit or 64-bit), or +you will get link errors. Also make sure you are using the binaries for your +version of Visual C++ or you may get other link errors. -When using MinGW to link an application with the static version of GLFW, you -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`. +There are two version of the static GLFW library in the binary archive, because +it needs to use the same base run-time library variant as the rest of your +executable. -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. +One is named `glfw3.lib` and is for projects with the _Runtime Library_ project +option set to _Multi-threaded DLL_ or _Multi-threaded Debug DLL_. The other is +named `glfw3_mt.lib` and is for projects with _Runtime Library_ set to +_Multi-threaded_ or _Multi-threaded Debug_. To use the static GLFW library you +will need to add `path/to/glfw3.lib` or `path/to/glfw3_mt.lib` to the +_Additional Dependencies_ project option. + +If you compiled a GLFW static library yourself then there will only be one, +named `glfw3.lib`, and you have to make sure the run-time library variant +matches. + +The DLL version of the GLFW library is named `glfw3.dll`, but you will be +linking against the `glfw3dll.lib` link library. To use the DLL you will need +to add `path/to/glfw3dll.lib` to the _Additional Dependencies_ project option. +All of its dependencies are already listed there by default, but when building +with the DLL version of GLFW, you also need to define the @ref GLFW_DLL. This +can be done either in the _Preprocessor Definitions_ project option or by +defining it in your source code before including the GLFW header. + +```c +#define GLFW_DLL +#include +``` + +All link-time dependencies for GLFW are already listed in the _Additional +Dependencies_ option by default. + + +### With MinGW-w64 and GLFW binaries {#build_link_mingw} + +This is intended for building a program from the command-line or by writing +a makefile, on Windows with [MinGW-w64][] and GLFW binaries. These can be from +a downloaded and extracted [binary archive](https://www.glfw.org/download.html) +or by compiling GLFW yourself. The paths below assume a binary archive is used. + +If you are using a downloaded binary archive, first make sure you have the +archive matching the architecture you are building for (32-bit or 64-bit) or you +will get link errors. + +Note that the order of source files and libraries matter for GCC. Dependencies +must be listed after the files that depend on them. Any source files that +depend on GLFW must be listed before the GLFW library. GLFW in turn depends on +`gdi32` and must be listed before it. + +[MinGW-w64]: https://www.mingw-w64.org/ + +If you are using the static version of the GLFW library, which is named +`libglfw3.a`, do: + +```sh +gcc -o myprog myprog.c -I path/to/glfw/include path/to/glfw/lib-mingw-w64/libglfw3.a -lgdi32 +``` + +If you are using the DLL version of the GLFW library, which is named +`glfw3.dll`, you will need to use the `libglfw3dll.a` link library. + +```sh +gcc -o myprog myprog.c -I path/to/glfw/include path/to/glfw/lib-mingw-w64/libglfw3dll.a -lgdi32 +``` + +The resulting executable will need to find `glfw3.dll` to run, typically by +keeping both files in the same directory. + +When you are building with the DLL version of GLFW, you will also need to define +the @ref GLFW_DLL macro. This can be done in your source files, as long as it +done before including the GLFW header: + +```c +#define GLFW_DLL +#include +``` + +It can also be done on the command-line: + +```sh +gcc -o myprog myprog.c -D GLFW_DLL -I path/to/glfw/include path/to/glfw/lib-mingw-w64/libglfw3dll.a -lgdi32 +``` ### With CMake and GLFW source {#build_link_cmake_source} @@ -264,7 +339,10 @@ target_link_libraries(myapp OpenGL::GL) ``` -### With makefiles and pkg-config on Unix {#build_link_pkgconfig} +### With pkg-config and GLFW binaries on Unix {#build_link_pkgconfig} + +This is intended for building a program from the command-line or by writing +a makefile, on macOS or any Unix-like system like Linux, FreeBSD and Cygwin. GLFW supports [pkg-config][], and the `glfw3.pc` pkg-config file is generated when the GLFW library is built and is installed along with it. A pkg-config @@ -316,13 +394,13 @@ OpenGL and IOKit frameworks to the project as dependencies. They can all be found in `/System/Library/Frameworks`. -### With command-line on macOS {#build_link_osx} +### With command-line or makefile on macOS {#build_link_osx} It is recommended that you use [pkg-config](@ref build_link_pkgconfig) when -building from the command line on macOS. That way you will get any new -dependencies added automatically. If you still wish to build manually, you need -to add the required frameworks and libraries to your command-line yourself using -the `-l` and `-framework` switches. +using installed GLFW binaries from the command line on macOS. That way you will +get any new dependencies added automatically. If you still wish to build +manually, you need to add the required frameworks and libraries to your +command-line yourself using the `-l` and `-framework` switches. If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do: From 421dc66afb383950cc3b49bc6d57d69e50e518c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Feb 2024 23:38:16 +0100 Subject: [PATCH 112/137] Remove reference to stale Coverity result --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b7ea493a..1ea70614 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Build status](https://github.com/glfw/glfw/actions/workflows/build.yml/badge.svg)](https://github.com/glfw/glfw/actions) [![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw) -[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw) ## Introduction From d7e7b164bc0df637d120f1f0543553f454ced091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 21 Feb 2024 00:17:32 +0100 Subject: [PATCH 113/137] Add credit Related to #2359 --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 26a2936a..c4c74ade 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -179,6 +179,7 @@ video tutorials. - n3rdopolis - Kristian Nielsen - Joel Niemelä + - Victor Nova - Kamil Nowakowski - onox - Denis Ovod From d45cbc82c92713e0669722251b3782d8b4e4a80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 21 Feb 2024 00:38:33 +0100 Subject: [PATCH 114/137] Fix error return value for glfwGetVideoMode The function returned a pointer to a zeroed video mode instead of NULL on error because errors were not propagated up from the platform. Fixes #1292 --- README.md | 1 + src/cocoa_monitor.m | 9 ++++++++- src/cocoa_platform.h | 2 +- src/internal.h | 2 +- src/monitor.c | 4 +++- src/null_monitor.c | 3 ++- src/null_platform.h | 2 +- src/win32_monitor.c | 10 ++++++++-- src/win32_platform.h | 2 +- src/wl_monitor.c | 3 ++- src/wl_platform.h | 2 +- src/x11_monitor.c | 17 +++++++++++++---- src/x11_platform.h | 2 +- 13 files changed, 43 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 1ea70614..6a9b3bfe 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ information on what to include when reporting a bug. - Disabled tests and examples by default when built as a CMake subdirectory - Removed `GLFW_USE_OSMESA` CMake option enabling the Null platform (#1958) - Removed CMake generated configuration header + - Bugfix: `glfwGetVideoMode` returned an invalid mode on error (#1292) - [Win32] Added a version info resource to the GLFW DLL - [Win32] Made hidden helper window use its own window class - [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index e351088a..641d5f0b 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -549,13 +549,20 @@ GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count) } // autoreleasepool } -void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode) +GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode) { @autoreleasepool { CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID); + if (!native) + { + _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to query display mode"); + return GLFW_FALSE; + } + *mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate); CGDisplayModeRelease(native); + return GLFW_TRUE; } // autoreleasepool } diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 3d424ee7..39914554 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -281,7 +281,7 @@ void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count); -void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); diff --git a/src/internal.h b/src/internal.h index 0d528875..88733593 100644 --- a/src/internal.h +++ b/src/internal.h @@ -700,7 +700,7 @@ struct _GLFWplatform void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*); void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*); GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*); - void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*); + GLFWbool (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*); GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*); void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*); // window diff --git a/src/monitor.c b/src/monitor.c index b76ac6db..efc286d5 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -450,7 +450,9 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle) _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _glfw.platform.getVideoMode(monitor, &monitor->currentMode); + if (!_glfw.platform.getVideoMode(monitor, &monitor->currentMode)) + return NULL; + return &monitor->currentMode; } diff --git a/src/null_monitor.c b/src/null_monitor.c index 63cd462f..d818f452 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -109,9 +109,10 @@ GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found) return mode; } -void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode) +GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode) { *mode = getVideoMode(); + return GLFW_TRUE; } GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp) diff --git a/src/null_platform.h b/src/null_platform.h index f9706acc..4843a76a 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -204,7 +204,7 @@ void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found); -void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 4edaf2c3..87c85b94 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -470,13 +470,17 @@ GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count) return result; } -void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode) +GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode) { DEVMODEW dm; ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); - EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm); + if (!EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm)) + { + _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to query display settings"); + return GLFW_FALSE; + } mode->width = dm.dmPelsWidth; mode->height = dm.dmPelsHeight; @@ -485,6 +489,8 @@ void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode) &mode->redBits, &mode->greenBits, &mode->blueBits); + + return GLFW_TRUE; } GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp) diff --git a/src/win32_platform.h b/src/win32_platform.h index feecb753..7e3d8845 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -609,7 +609,7 @@ void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count); -void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 66639301..df30313a 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -232,9 +232,10 @@ GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found) return monitor->modes; } -void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode) +GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode) { *mode = monitor->modes[monitor->wl.currentMode]; + return GLFW_TRUE; } GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp) diff --git a/src/wl_platform.h b/src/wl_platform.h index b3478df1..149cd241 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -679,7 +679,7 @@ void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count); -void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 31640fb1..38af7e0c 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -491,24 +491,31 @@ GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count) return result; } -void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode) +GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode) { if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); - XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); + const XRRModeInfo* mi = NULL; + XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); if (ci) { - const XRRModeInfo* mi = getModeInfo(sr, ci->mode); - if (mi) // mi can be NULL if the monitor has been disconnected + mi = getModeInfo(sr, ci->mode); + if (mi) *mode = vidmodeFromModeInfo(mi, ci); XRRFreeCrtcInfo(ci); } XRRFreeScreenResources(sr); + + if (!mi) + { + _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to query video mode"); + return GLFW_FALSE; + } } else { @@ -519,6 +526,8 @@ void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode) _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen), &mode->redBits, &mode->greenBits, &mode->blueBits); } + + return GLFW_TRUE; } GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp) diff --git a/src/x11_platform.h b/src/x11_platform.h index cdea3957..14e363d1 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -968,7 +968,7 @@ void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count); -void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); From fb9c23fbf2ff94dfd26b5ccf78292b6fb92744b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 21 Feb 2024 15:34:36 +0100 Subject: [PATCH 115/137] Build has been tested with CMake 3.28 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0904b7e..03ad3e71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR) +cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR) project(GLFW VERSION 3.4.0 LANGUAGES C) From 415df7e3ba7a3a29e75f2ee537a865c2ff53b822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 21 Feb 2024 15:37:15 +0100 Subject: [PATCH 116/137] Wayland: Explain what to do when the build fails That would be a helpful thing to do. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03ad3e71..a3cb1fe6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ endif() if (DEFINED GLFW_USE_WAYLAND AND UNIX AND NOT APPLE) message(FATAL_ERROR - "GLFW_USE_WAYLAND has been removed; set the GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 options") + "GLFW_USE_WAYLAND has been removed; delete the CMake cache and set GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 instead") endif() cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF) From 4d9557aefe46ca3cab4fecc73f22701e07b185e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 22 Feb 2024 20:20:50 +0100 Subject: [PATCH 117/137] Update README for 3.3.10 release --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a9b3bfe..c1e9f27a 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for information on what to include when reporting a bug. -## Changelog since 3.3.9 +## Changelog since 3.3.10 - Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958) - Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, From 523d1d61ca73aa5456e8f15b41d3d9ad3f80631e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Feb 2024 15:22:24 +0100 Subject: [PATCH 118/137] Remove outline of Doxygen 1.9.8 menu links --- docs/extra.css | 2 +- docs/extra.css.map | 2 +- docs/extra.scss | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/extra.css b/docs/extra.css index 1a287343..7eb7e9d9 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -1,2 +1,2 @@ -.sm-dox,.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted,.sm-dox ul a:hover{background:none;text-shadow:none}.sm-dox a span.sub-arrow{border-color:#f2f2f2 transparent transparent transparent}.sm-dox a span.sub-arrow:active,.sm-dox a span.sub-arrow:focus,.sm-dox a span.sub-arrow:hover,.sm-dox a:hover span.sub-arrow{border-color:#f60 transparent transparent transparent}.sm-dox ul a span.sub-arrow:active,.sm-dox ul a span.sub-arrow:focus,.sm-dox ul a span.sub-arrow:hover,.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent #f60}.sm-dox ul a:hover{background:#666;text-shadow:none}.sm-dox ul.sm-nowrap a{color:#4d4d4d;text-shadow:none}#main-nav,#main-menu,#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code,.markdownTable code{background:none}#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,table.markdownTable td,table.markdownTable th,hr,.memSeparator{border:none}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.reflist dt a.el,.levels span,.directory .levels span{text-shadow:none}.memdoc,dl.reflist dd{box-shadow:none}div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code,table.markdownTable code{padding:0}#nav-path,.directory .levels,span.lineno{display:none}html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),tr.markdownTableBody:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code,.markdownTableRowEven{background:#f2f2f2}body{color:#4d4d4d}div.title{font-size:170%;margin:1em 0 0.5em 0}h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em{color:#1a1a1a;border-bottom:none}h1{padding-top:0.5em;font-size:150%}h2{padding-top:0.5em;margin-bottom:0;font-size:130%}h3{padding-top:0.5em;margin-bottom:0;font-size:110%}.glfwheader{font-size:16px;min-height:64px;max-width:920px;padding:0 32px;margin:0 auto;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#glfwhome{line-height:64px;padding-right:48px;color:#666;font-size:2.5em;background:url("https://www.glfw.org/css/arrow.png") no-repeat right}.glfwnavbar{list-style-type:none;margin:0 0 0 auto;float:right}#glfwhome,.glfwnavbar li{float:left}.glfwnavbar a,.glfwnavbar a:visited{line-height:64px;margin-left:2em;display:block;color:#666}.glfwnavbar{padding-left:0}#glfwhome,.glfwnavbar a,.glfwnavbar a:visited{transition:.35s ease}#titlearea,.footer{color:#666}address.footer{text-align:center;padding:2em;margin-top:3em}#top{background:#666}#main-nav{max-width:960px;margin:0 auto;font-size:13px}#main-menu{max-width:920px;margin:0 auto;font-size:13px}.memtitle{display:none}.memproto,.memname{font-weight:bold;text-shadow:none}#main-menu{min-height:36px;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li{color:#f2f2f2}#main-menu li ul.sm-nowrap li a{color:#4d4d4d}#main-menu li ul.sm-nowrap li a:hover{color:#f60}#main-menu>li:last-child{margin:0 0 0 auto}.contents{min-height:590px}div.contents,div.header{max-width:920px;margin:0 auto;padding:0 32px;background:#fff none}table.doxtable th,table.markdownTable th,dl.reflist dt{background:linear-gradient(to bottom, #ffa733 0%, #f60 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;text-align:left;color:#fff}dl.reflist dt a.el{color:#f60;padding:.2em;border-radius:4px;background-color:#ffe0cc}div.toc{float:right;width:35%}@media screen and (max-width: 600px){div.toc{float:none;width:inherit;margin:0}}div.toc h3{font-size:1.17em}div.toc ul{padding-left:1.5em}div.toc li{font-size:1em;padding-left:0;list-style-type:disc}div.toc li.level2,div.toc li.level3{margin-left:0.5em}div.toc,.memproto,div.qindex,div.ah{background:linear-gradient(to bottom, #f2f2f2 0%, #e6e6e6 100%);box-shadow:inset 0 0 32px #e6e6e6;text-shadow:0 1px 1px #fff;color:#1a1a1a;border:2px solid #e6e6e6;border-radius:4px}.paramname{color:#803300}dl.reflist dt{border:2px solid #f60;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:none}dl.reflist dd{border:2px solid #f60;border-bottom-right-radius:4px;border-bottom-left-radius:4px;border-top:none}table.doxtable,table.markdownTable{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,#main-menu a:hover,span.lineno a:hover{color:#f60;text-decoration:none}div.directory{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}hr,.memSeparator{height:2px;background:linear-gradient(to right, #f2f2f2 0%, #d9d9d9 50%, #f2f2f2 100%)}dl.note,dl.pre,dl.post,dl.invariant{background:linear-gradient(to bottom, #ddfad1 0%, #cbf7ba 100%);box-shadow:inset 0 0 32px #baf5a3;color:#1e5309;border:2px solid #afe699}dl.warning,dl.attention{background:linear-gradient(to bottom, #fae8d1 0%, #f7ddba 100%);box-shadow:inset 0 0 32px #f5d1a3;color:#533309;border:2px solid #e6c499}dl.deprecated,dl.bug{background:linear-gradient(to bottom, #fad1e3 0%, #f7bad6 100%);box-shadow:inset 0 0 32px #f5a3c8;color:#53092a;border:2px solid #e699bb}dl.todo,dl.test{background:linear-gradient(to bottom, #d1ecfa 0%, #bae3f7 100%);box-shadow:inset 0 0 32px #a3daf5;color:#093a53;border:2px solid #99cce6}dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test{border-radius:4px;padding:1em;text-shadow:0 1px 1px #fff;margin:1em 0}.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited{color:inherit}div.line{line-height:inherit}div.fragment,pre.fragment{background:#f2f2f2;border-radius:4px;border:none;padding:1em;overflow:auto;border-left:4px solid #ccc;margin:1em 0}.lineno a,.lineno a:visited,.line,pre.fragment{color:#4d4d4d}span.preprocessor,span.comment{color:#007899}a.code,a.code:visited{color:#e64500}span.keyword,span.keywordtype,span.keywordflow{color:#404040;font-weight:bold}span.stringliteral{color:#360099}code{padding:.1em;border-radius:4px} +.sm-dox,.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted,.sm-dox ul a:hover{background:none;text-shadow:none}.sm-dox a span.sub-arrow{border-color:#f2f2f2 transparent transparent transparent}.sm-dox a span.sub-arrow:active,.sm-dox a span.sub-arrow:focus,.sm-dox a span.sub-arrow:hover,.sm-dox a:hover span.sub-arrow{border-color:#f60 transparent transparent transparent}.sm-dox ul a span.sub-arrow:active,.sm-dox ul a span.sub-arrow:focus,.sm-dox ul a span.sub-arrow:hover,.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent #f60}.sm-dox ul a:hover{background:#666;text-shadow:none}.sm-dox ul.sm-nowrap a{color:#4d4d4d;text-shadow:none}#main-nav,#main-menu,#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code,.markdownTable code{background:none}#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,table.markdownTable td,table.markdownTable th,hr,.memSeparator{border:none}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.reflist dt a.el,.levels span,.directory .levels span{text-shadow:none}.memdoc,dl.reflist dd{box-shadow:none}div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code,table.markdownTable code{padding:0}#nav-path,.directory .levels,span.lineno{display:none}html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),tr.markdownTableBody:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code,.markdownTableRowEven{background:#f2f2f2}body{color:#4d4d4d}div.title{font-size:170%;margin:1em 0 0.5em 0}h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em{color:#1a1a1a;border-bottom:none}h1{padding-top:0.5em;font-size:150%}h2{padding-top:0.5em;margin-bottom:0;font-size:130%}h3{padding-top:0.5em;margin-bottom:0;font-size:110%}.glfwheader{font-size:16px;min-height:64px;max-width:920px;padding:0 32px;margin:0 auto;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#glfwhome{line-height:64px;padding-right:48px;color:#666;font-size:2.5em;background:url("https://www.glfw.org/css/arrow.png") no-repeat right}.glfwnavbar{list-style-type:none;margin:0 0 0 auto;float:right}#glfwhome,.glfwnavbar li{float:left}.glfwnavbar a,.glfwnavbar a:visited{line-height:64px;margin-left:2em;display:block;color:#666}.glfwnavbar{padding-left:0}#glfwhome,.glfwnavbar a,.glfwnavbar a:visited{transition:.35s ease}#titlearea,.footer{color:#666}address.footer{text-align:center;padding:2em;margin-top:3em}#top{background:#666}#main-nav{max-width:960px;margin:0 auto;font-size:13px}#main-menu{max-width:920px;margin:0 auto;font-size:13px}.memtitle{display:none}.memproto,.memname{font-weight:bold;text-shadow:none}#main-menu{min-height:36px;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#main-menu a:focus{outline-style:none}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li{color:#f2f2f2}#main-menu li ul.sm-nowrap li a{color:#4d4d4d}#main-menu li ul.sm-nowrap li a:hover{color:#f60}#main-menu>li:last-child{margin:0 0 0 auto}.contents{min-height:590px}div.contents,div.header{max-width:920px;margin:0 auto;padding:0 32px;background:#fff none}table.doxtable th,table.markdownTable th,dl.reflist dt{background:linear-gradient(to bottom, #ffa733 0%, #f60 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;text-align:left;color:#fff}dl.reflist dt a.el{color:#f60;padding:.2em;border-radius:4px;background-color:#ffe0cc}div.toc{float:right;width:35%}@media screen and (max-width: 600px){div.toc{float:none;width:inherit;margin:0}}div.toc h3{font-size:1.17em}div.toc ul{padding-left:1.5em}div.toc li{font-size:1em;padding-left:0;list-style-type:disc}div.toc li.level2,div.toc li.level3{margin-left:0.5em}div.toc,.memproto,div.qindex,div.ah{background:linear-gradient(to bottom, #f2f2f2 0%, #e6e6e6 100%);box-shadow:inset 0 0 32px #e6e6e6;text-shadow:0 1px 1px #fff;color:#1a1a1a;border:2px solid #e6e6e6;border-radius:4px}.paramname{color:#803300}dl.reflist dt{border:2px solid #f60;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:none}dl.reflist dd{border:2px solid #f60;border-bottom-right-radius:4px;border-bottom-left-radius:4px;border-top:none}table.doxtable,table.markdownTable{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,#main-menu a:hover,span.lineno a:hover{color:#f60;text-decoration:none}div.directory{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}hr,.memSeparator{height:2px;background:linear-gradient(to right, #f2f2f2 0%, #d9d9d9 50%, #f2f2f2 100%)}dl.note,dl.pre,dl.post,dl.invariant{background:linear-gradient(to bottom, #ddfad1 0%, #cbf7ba 100%);box-shadow:inset 0 0 32px #baf5a3;color:#1e5309;border:2px solid #afe699}dl.warning,dl.attention{background:linear-gradient(to bottom, #fae8d1 0%, #f7ddba 100%);box-shadow:inset 0 0 32px #f5d1a3;color:#533309;border:2px solid #e6c499}dl.deprecated,dl.bug{background:linear-gradient(to bottom, #fad1e3 0%, #f7bad6 100%);box-shadow:inset 0 0 32px #f5a3c8;color:#53092a;border:2px solid #e699bb}dl.todo,dl.test{background:linear-gradient(to bottom, #d1ecfa 0%, #bae3f7 100%);box-shadow:inset 0 0 32px #a3daf5;color:#093a53;border:2px solid #99cce6}dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test{border-radius:4px;padding:1em;text-shadow:0 1px 1px #fff;margin:1em 0}.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited{color:inherit}div.line{line-height:inherit}div.fragment,pre.fragment{background:#f2f2f2;border-radius:4px;border:none;padding:1em;overflow:auto;border-left:4px solid #ccc;margin:1em 0}.lineno a,.lineno a:visited,.line,pre.fragment{color:#4d4d4d}span.preprocessor,span.comment{color:#007899}a.code,a.code:visited{color:#e64500}span.keyword,span.keywordtype,span.keywordflow{color:#404040;font-weight:bold}span.stringliteral{color:#360099}code{padding:.1em;border-radius:4px} /*# sourceMappingURL=extra.css.map */ diff --git a/docs/extra.css.map b/docs/extra.css.map index 4d9333c2..d9a5d7d3 100644 --- a/docs/extra.css.map +++ b/docs/extra.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AA8EA,2GAA4G,CAC3G,UAAU,CAAC,IAAI,CACf,WAAW,CAAC,IAAI,CAGjB,wBAAyB,CACxB,YAAY,CAAC,2CAAsD,CAGpE,4HAA6H,CAC5H,YAAY,CAAC,wCAAuD,CAGrE,wIAAyI,CACxI,YAAY,CAAC,wCAAuD,CAGrE,kBAAmB,CAClB,UAAU,CA9EgB,IAAa,CA+EvC,WAAW,CAAC,IAAI,CAGjB,sBAAuB,CACtB,KAAK,CAzFe,OAAa,CA0FjC,WAAW,CAAC,IAAI,CAGjB,4UAA6U,CAC5U,UAAU,CAAC,IAAI,CAGhB,kJAAmJ,CAClJ,MAAM,CAAC,IAAI,CAGZ,wHAAyH,CACxH,WAAW,CAAC,IAAI,CAGjB,qBAAsB,CACrB,UAAU,CAAC,IAAI,CAGhB,2LAA4L,CAC3L,OAAO,CAAC,CAAC,CAGV,wCAAyC,CACxC,OAAO,CAAC,IAAI,CAGb,iMAAkM,CACjM,UAAU,CApGW,OAA+B,CAuGrD,IAAK,CACJ,KAAK,CA1He,OAAa,CA6HlC,SAAU,CACN,SAAS,CAAE,IAAI,CACf,MAAM,CAAE,aAAa,CAGzB,qDAAsD,CACrD,KAAK,CApHU,OAAa,CAqH5B,aAAa,CAAC,IAAI,CAGnB,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,WAAY,CACX,SAAS,CAAC,IAAI,CACd,UAAU,CAAC,IAAI,CACf,SAAS,CAAC,KAAK,CACf,OAAO,CAAC,MAAM,CACd,MAAM,CAAC,MAAM,CAEb,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,SAAU,CACT,WAAW,CAAC,IAAI,CAChB,aAAa,CAAC,IAAI,CAClB,KAAK,CApKqB,IAAa,CAqKvC,SAAS,CAAC,KAAK,CACf,UAAU,CAAC,yDAAyD,CAGrE,WAAY,CACX,eAAe,CAAC,IAAI,CACpB,MAAM,CAAC,UAAU,CACjB,KAAK,CAAC,KAAK,CAGZ,wBAAyB,CACxB,KAAK,CAAC,IAAI,CAGX,mCAAoC,CACnC,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,GAAG,CACf,OAAO,CAAC,KAAK,CACb,KAAK,CAvLqB,IAAa,CA0LxC,WAAY,CACX,YAAY,CAAE,CAAC,CAGhB,6CAA8C,CAC7C,UAAU,CAAC,SAAS,CAGrB,kBAAmB,CAClB,KAAK,CAnMqB,IAAa,CAsMxC,cAAe,CACd,UAAU,CAAC,MAAM,CACjB,OAAO,CAAC,GAAG,CACX,UAAU,CAAC,GAAG,CAGf,IAAK,CACJ,UAAU,CA7MgB,IAAa,CAgNxC,SAAU,CACT,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,UAAW,CACV,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,SAAU,CACT,OAAO,CAAC,IAAI,CAGb,kBAAmB,CAClB,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,IAAI,CAGjB,UAAW,CACV,UAAU,CAAC,IAAI,CACf,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,kEAAmE,CAClE,KAAK,CApOgB,OAA+B,CAuOrD,+BAAgC,CAC/B,KAAK,CA1Pe,OAAa,CA6PlC,qCAAsC,CACrC,KAAK,CA1NoB,IAAsB,CA6NhD,wBAA2B,CAC1B,MAAM,CAAE,UAAU,CAGnB,SAAU,CACT,UAAU,CAAC,KAAK,CAGjB,uBAAwB,CACvB,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,OAAO,CAAC,MAAM,CACd,UAAU,CAAC,SAA8B,CAG1C,sDAAuD,CACtD,UAAU,CAAC,iDAAoF,CAC/F,UAAU,CAAC,mBAAuC,CAClD,WAAW,CAAC,kBAAgD,CAC5D,UAAU,CAAC,IAAI,CACf,KAAK,CAlPa,IAAe,CAqPlC,kBAAmB,CAClB,KAAK,CArPoB,IAAsB,CAsP/C,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG,CACjB,gBAAgB,CAAC,OAAiC,CAGnD,OAAQ,CACP,KAAK,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAGV,oCAAoC,CACnC,OAAQ,CACP,KAAK,CAAC,IAAI,CACV,KAAK,CAAC,OAAO,CACb,MAAM,CAAC,CAAC,EAIV,UAAW,CACV,SAAS,CAAC,MAAM,CAGjB,UAAW,CACV,YAAY,CAAC,KAAK,CAGnB,UAAW,CACV,SAAS,CAAC,GAAG,CACb,YAAY,CAAC,CAAC,CACd,eAAe,CAAC,IAAI,CAIjB,mCAAqB,CACjB,WAAW,CAAC,KAAK,CAIzB,mCAAoC,CACnC,UAAU,CAAC,oDAAgF,CAC3F,UAAU,CAAC,sBAAqC,CAChD,WAAW,CAAC,cAA8C,CAC1D,KAAK,CArTU,OAAa,CAsT5B,MAAM,CAAC,iBAAgC,CACvC,aAAa,CAAC,GAAG,CAGlB,UAAW,CACV,KAAK,CA9RkB,OAAgC,CAiSxD,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,sBAAsB,CAAC,GAAG,CAC1B,uBAAuB,CAAC,GAAG,CAC3B,aAAa,CAAC,IAAI,CAGnB,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,0BAA0B,CAAC,GAAG,CAC9B,yBAAyB,CAAC,GAAG,CAC7B,UAAU,CAAC,IAAI,CAGhB,kCAAmC,CAClC,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,+HAAgI,CAC/H,KAAK,CA/ToB,IAAsB,CAgU/C,eAAe,CAAC,IAAI,CAGrB,aAAc,CACb,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,gBAAiB,CAChB,MAAM,CAAC,GAAG,CACV,UAAU,CAAC,gEAAiH,CAG7H,mCAAoC,CAvTnC,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAwT3D,uBAAwB,CA3TvB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CA4T3D,oBAAqB,CA/TpB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAgU3D,eAAgB,CAnUf,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAoU3D,gGAAiG,CAChG,aAAa,CAAC,GAAG,CACjB,OAAO,CAAC,GAAG,CACX,WAAW,CAAC,cAAwB,CACpC,MAAM,CAAC,KAAK,CAGb,iRAAkR,CACjR,KAAK,CAAC,OAAO,CAGd,QAAS,CACR,WAAW,CAAC,OAAO,CAGpB,yBAA0B,CACzB,UAAU,CAAC,OAAa,CACxB,aAAa,CAAC,GAAG,CACjB,MAAM,CAAC,IAAI,CACX,OAAO,CAAC,GAAG,CACX,QAAQ,CAAC,IAAI,CACb,WAAW,CAAC,cAAuB,CACnC,MAAM,CAAC,KAAK,CAGb,8CAA+C,CAC9C,KAAK,CA7Ze,OAAa,CAgalC,8BAA+B,CAC9B,KAAK,CAAC,OAAiB,CAGxB,qBAAsB,CACrB,KAAK,CAAC,OAAgB,CAGvB,8CAA+C,CAC9C,KAAK,CAAC,OAA+B,CACrC,WAAW,CAAC,IAAI,CAGjB,kBAAmB,CAClB,KAAK,CAAC,OAAiB,CAGxB,IAAK,CACJ,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG", +"mappings": "AA8EA,2GAA4G,CAC3G,UAAU,CAAC,IAAI,CACf,WAAW,CAAC,IAAI,CAGjB,wBAAyB,CACxB,YAAY,CAAC,2CAAsD,CAGpE,4HAA6H,CAC5H,YAAY,CAAC,wCAAuD,CAGrE,wIAAyI,CACxI,YAAY,CAAC,wCAAuD,CAGrE,kBAAmB,CAClB,UAAU,CA9EgB,IAAa,CA+EvC,WAAW,CAAC,IAAI,CAGjB,sBAAuB,CACtB,KAAK,CAzFe,OAAa,CA0FjC,WAAW,CAAC,IAAI,CAGjB,4UAA6U,CAC5U,UAAU,CAAC,IAAI,CAGhB,kJAAmJ,CAClJ,MAAM,CAAC,IAAI,CAGZ,wHAAyH,CACxH,WAAW,CAAC,IAAI,CAGjB,qBAAsB,CACrB,UAAU,CAAC,IAAI,CAGhB,2LAA4L,CAC3L,OAAO,CAAC,CAAC,CAGV,wCAAyC,CACxC,OAAO,CAAC,IAAI,CAGb,iMAAkM,CACjM,UAAU,CApGW,OAA+B,CAuGrD,IAAK,CACJ,KAAK,CA1He,OAAa,CA6HlC,SAAU,CACN,SAAS,CAAE,IAAI,CACf,MAAM,CAAE,aAAa,CAGzB,qDAAsD,CACrD,KAAK,CApHU,OAAa,CAqH5B,aAAa,CAAC,IAAI,CAGnB,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,EAAG,CACF,WAAW,CAAC,KAAK,CACjB,aAAa,CAAC,CAAC,CACf,SAAS,CAAC,IAAI,CAGf,WAAY,CACX,SAAS,CAAC,IAAI,CACd,UAAU,CAAC,IAAI,CACf,SAAS,CAAC,KAAK,CACf,OAAO,CAAC,MAAM,CACd,MAAM,CAAC,MAAM,CAEb,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,SAAU,CACT,WAAW,CAAC,IAAI,CAChB,aAAa,CAAC,IAAI,CAClB,KAAK,CApKqB,IAAa,CAqKvC,SAAS,CAAC,KAAK,CACf,UAAU,CAAC,yDAAyD,CAGrE,WAAY,CACX,eAAe,CAAC,IAAI,CACpB,MAAM,CAAC,UAAU,CACjB,KAAK,CAAC,KAAK,CAGZ,wBAAyB,CACxB,KAAK,CAAC,IAAI,CAGX,mCAAoC,CACnC,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,GAAG,CACf,OAAO,CAAC,KAAK,CACb,KAAK,CAvLqB,IAAa,CA0LxC,WAAY,CACX,YAAY,CAAE,CAAC,CAGhB,6CAA8C,CAC7C,UAAU,CAAC,SAAS,CAGrB,kBAAmB,CAClB,KAAK,CAnMqB,IAAa,CAsMxC,cAAe,CACd,UAAU,CAAC,MAAM,CACjB,OAAO,CAAC,GAAG,CACX,UAAU,CAAC,GAAG,CAGf,IAAK,CACJ,UAAU,CA7MgB,IAAa,CAgNxC,SAAU,CACT,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,UAAW,CACV,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,SAAS,CAAC,IAAI,CAGf,SAAU,CACT,OAAO,CAAC,IAAI,CAGb,kBAAmB,CAClB,WAAW,CAAC,IAAI,CAChB,WAAW,CAAC,IAAI,CAGjB,UAAW,CACV,UAAU,CAAC,IAAI,CACf,OAAO,CAAE,IAAI,CACb,cAAc,CAAE,GAAG,CACnB,SAAS,CAAE,IAAI,CACf,eAAe,CAAE,UAAU,CAC3B,WAAW,CAAE,MAAM,CACnB,aAAa,CAAE,OAAO,CAGvB,kBAAmB,CACf,aAAa,CAAE,IAAI,CAGvB,kEAAmE,CAClE,KAAK,CAxOgB,OAA+B,CA2OrD,+BAAgC,CAC/B,KAAK,CA9Pe,OAAa,CAiQlC,qCAAsC,CACrC,KAAK,CA9NoB,IAAsB,CAiOhD,wBAA2B,CAC1B,MAAM,CAAE,UAAU,CAGnB,SAAU,CACT,UAAU,CAAC,KAAK,CAGjB,uBAAwB,CACvB,SAAS,CAAC,KAAK,CACf,MAAM,CAAC,MAAM,CACb,OAAO,CAAC,MAAM,CACd,UAAU,CAAC,SAA8B,CAG1C,sDAAuD,CACtD,UAAU,CAAC,iDAAoF,CAC/F,UAAU,CAAC,mBAAuC,CAClD,WAAW,CAAC,kBAAgD,CAC5D,UAAU,CAAC,IAAI,CACf,KAAK,CAtPa,IAAe,CAyPlC,kBAAmB,CAClB,KAAK,CAzPoB,IAAsB,CA0P/C,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG,CACjB,gBAAgB,CAAC,OAAiC,CAGnD,OAAQ,CACP,KAAK,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CAGV,oCAAoC,CACnC,OAAQ,CACP,KAAK,CAAC,IAAI,CACV,KAAK,CAAC,OAAO,CACb,MAAM,CAAC,CAAC,EAIV,UAAW,CACV,SAAS,CAAC,MAAM,CAGjB,UAAW,CACV,YAAY,CAAC,KAAK,CAGnB,UAAW,CACV,SAAS,CAAC,GAAG,CACb,YAAY,CAAC,CAAC,CACd,eAAe,CAAC,IAAI,CAIjB,mCAAqB,CACjB,WAAW,CAAC,KAAK,CAIzB,mCAAoC,CACnC,UAAU,CAAC,oDAAgF,CAC3F,UAAU,CAAC,sBAAqC,CAChD,WAAW,CAAC,cAA8C,CAC1D,KAAK,CAzTU,OAAa,CA0T5B,MAAM,CAAC,iBAAgC,CACvC,aAAa,CAAC,GAAG,CAGlB,UAAW,CACV,KAAK,CAlSkB,OAAgC,CAqSxD,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,sBAAsB,CAAC,GAAG,CAC1B,uBAAuB,CAAC,GAAG,CAC3B,aAAa,CAAC,IAAI,CAGnB,aAAc,CACb,MAAM,CAAC,cAA+B,CACtC,0BAA0B,CAAC,GAAG,CAC9B,yBAAyB,CAAC,GAAG,CAC7B,UAAU,CAAC,IAAI,CAGhB,kCAAmC,CAClC,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,+HAAgI,CAC/H,KAAK,CAnUoB,IAAsB,CAoU/C,eAAe,CAAC,IAAI,CAGrB,aAAc,CACb,eAAe,CAAC,OAAO,CACvB,cAAc,CAAC,CAAC,CAChB,MAAM,CAAC,cAA+B,CACtC,aAAa,CAAC,GAAG,CAGlB,gBAAiB,CAChB,MAAM,CAAC,GAAG,CACV,UAAU,CAAC,gEAAiH,CAG7H,mCAAoC,CA3TnC,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CA4T3D,uBAAwB,CA/TvB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAgU3D,oBAAqB,CAnUpB,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAoU3D,eAAgB,CAvUf,UAAU,CAAC,oDAAuE,CAClF,UAAU,CAAC,sBAAsC,CACjD,KAAK,CAAC,OAAwB,CAC9B,MAAM,CAAC,iBAAmD,CAwU3D,gGAAiG,CAChG,aAAa,CAAC,GAAG,CACjB,OAAO,CAAC,GAAG,CACX,WAAW,CAAC,cAAwB,CACpC,MAAM,CAAC,KAAK,CAGb,iRAAkR,CACjR,KAAK,CAAC,OAAO,CAGd,QAAS,CACR,WAAW,CAAC,OAAO,CAGpB,yBAA0B,CACzB,UAAU,CAAC,OAAa,CACxB,aAAa,CAAC,GAAG,CACjB,MAAM,CAAC,IAAI,CACX,OAAO,CAAC,GAAG,CACX,QAAQ,CAAC,IAAI,CACb,WAAW,CAAC,cAAuB,CACnC,MAAM,CAAC,KAAK,CAGb,8CAA+C,CAC9C,KAAK,CAjae,OAAa,CAoalC,8BAA+B,CAC9B,KAAK,CAAC,OAAiB,CAGxB,qBAAsB,CACrB,KAAK,CAAC,OAAgB,CAGvB,8CAA+C,CAC9C,KAAK,CAAC,OAA+B,CACrC,WAAW,CAAC,IAAI,CAGjB,kBAAmB,CAClB,KAAK,CAAC,OAAiB,CAGxB,IAAK,CACJ,OAAO,CAAC,IAAI,CACZ,aAAa,CAAC,GAAG", "sources": ["extra.scss"], "names": [], "file": "extra.css" diff --git a/docs/extra.scss b/docs/extra.scss index 43fe9831..acf28e21 100644 --- a/docs/extra.scss +++ b/docs/extra.scss @@ -255,6 +255,10 @@ address.footer { align-content: stretch; } +#main-menu a:focus { + outline-style: none; +} + #main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li { color:$navbar-link-color; } From e14e72a2e7b171b17b2aee945b081bb56e5e37d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 22 Feb 2024 22:32:03 +0100 Subject: [PATCH 119/137] De-emphasize FAQ Until it can be properly rewritten. --- docs/main.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/main.md b/docs/main.md index 4f86b8af..974e5fce 100644 --- a/docs/main.md +++ b/docs/main.md @@ -29,9 +29,6 @@ use the new API. There is a section on @ref guarantees_limitations for pointer lifetimes, reentrancy, thread safety, event order and backward and forward compatibility. -The [FAQ](https://www.glfw.org/faq.html) answers many common questions about the -design, implementation and use of GLFW. - Finally, @ref compat_guide explains what APIs, standards and protocols GLFW uses and what happens when they are not present on a given machine. From 7b6aead9fb88b3623e3b3725ebb42670cbe4c579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 22 Feb 2024 22:22:47 +0100 Subject: [PATCH 120/137] Documentation updates for 3.4 release --- README.md | 8 +- docs/main.md | 2 +- docs/news.md | 282 ++++++++++++++++++++++++++++++++------------------- 3 files changed, 180 insertions(+), 112 deletions(-) diff --git a/README.md b/README.md index c1e9f27a..efd1383f 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ GLFW is licensed under the [zlib/libpng license](https://www.glfw.org/license.html). You can [download](https://www.glfw.org/download.html) the latest stable release -as source or Windows binaries, or fetch the `latest` branch from GitHub. Each -release starting with 3.0 also has a corresponding [annotated -tag](https://github.com/glfw/glfw/releases) with source and binary archives. +as source or Windows binaries. Each release starting with 3.0 also has +a corresponding [annotated tag](https://github.com/glfw/glfw/releases) with +source and binary archives. The [documentation](https://www.glfw.org/docs/latest/) is available online and is included in all source and binary archives. See the [release @@ -170,7 +170,7 @@ information on what to include when reporting a bug. - Made joystick subsystem initialize at first use (#1284,#1646) - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Made Wayland the preferred platform over X11 if both are available (#2035) - - Updated the minimum required CMake version to 3.1 + - Updated the minimum required CMake version to 3.4 - Updated gamepad mappings from upstream - Renamed `GLFW_USE_WAYLAND` CMake option to `GLFW_BUILD_WAYLAND` (#1958) - Disabled tests and examples by default when built as a CMake subdirectory diff --git a/docs/main.md b/docs/main.md index 974e5fce..c70f735f 100644 --- a/docs/main.md +++ b/docs/main.md @@ -4,7 +4,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_34 list new features, caveats and deprecations. +@ref news 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.md b/docs/news.md index e68464f6..3be95488 100644 --- a/docs/news.md +++ b/docs/news.md @@ -1,27 +1,21 @@ -# Release notes {#news} +# Release notes for version 3.4 {#news} [TOC] -## Release notes for version 3.4 {#news_34} +## New features {#features} -### New features in version 3.4 {#features_34} - -#### Cocoa NSView native access function {#native_cocoa_nsview_34} - -GLFW now provides the @ref glfwGetCocoaView native access function -for returning the Cocoa NSView. - - -#### Runtime platform selection {#runtime_platform_34} +### Runtime platform selection {#runtime_platform_selection} GLFW now supports being compiled for multiple backends and selecting between them at runtime with the @ref GLFW_PLATFORM init hint. After initialization the selected platform can be queried with @ref glfwGetPlatform. You can check if support for a given platform is compiled in with @ref glfwPlatformSupported. +For more information see @ref platform. -#### More standard cursor shapes {#standard_cursors_34} + +### More standard cursor shapes {#more_cursor_shapes} 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 @@ -39,7 +33,7 @@ are still available. For more information see @ref cursor_standard. -#### Mouse event passthrough {#mouse_passthrough_34} +### Mouse event passthrough {#mouse_input_passthrough} GLFW now provides the [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint) window hint for making a window transparent to mouse input, lettings events pass @@ -47,7 +41,7 @@ to whatever window is behind it. This can also be changed after window creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib). -#### Ability to get window title {#features_34_window_title} +### Ability to get window title {#window_title_function} GLFW now supports querying the title of a window with the @ref glfwGetWindowTitle function. @@ -55,7 +49,7 @@ function. For more information see @ref window_title. -#### Captured cursor mode {#captured_cursor_34} +### Captured cursor mode {#captured_cursor_mode} GLFW now supports confining the cursor to the window content area with the @ref GLFW_CURSOR_CAPTURED cursor mode. @@ -63,17 +57,17 @@ GLFW_CURSOR_CAPTURED cursor mode. For more information see @ref cursor_mode. -#### Support for custom heap memory allocator {#features_34_init_allocator} +### Support for custom heap memory allocator {#custom_heap_allocator} -GLFW now supports plugging a custom memory allocator at initialization with @ref -glfwInitAllocator. The allocator is a struct of type @ref GLFWallocator with -function pointers corresponding to the standard library functions `malloc`, +GLFW now supports plugging a custom heap memory allocator at initialization with +@ref glfwInitAllocator. The allocator is a struct of type @ref GLFWallocator +with function pointers corresponding to the standard library functions `malloc`, `realloc` and `free`. For more information see @ref init_allocator. -#### Window hint for framebuffer scaling {#scale_framebuffer_34} +### Window hint for framebuffer scaling {#scale_framebuffer_hint} GLFW now allows provides the [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for @@ -83,13 +77,12 @@ allow framebuffer scaling. This was already possible on macOS via the [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) window -hint. This hint is now another name for -[GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint). +hint. This is now another name for the same hint value. For more information see @ref window_scale. -#### Window hints for initial window position {#features_34_position_hint} +### Window hints for initial window position {#window_position_hint} GLFW now provides the @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints for specifying the initial position of the window. This removes the need to create a hidden @@ -99,39 +92,7 @@ window, move it and then show it. The default value of these hints is For more information see @ref window_pos. -#### Support for keyboard access to Windows window menu {#features_34_win32_keymenu} - -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. - - -#### Support for applying STARTUPINFO show command {#features_34_win32_showdefault} - -GLFW now provides the [GLFW_WIN32_SHOWDEFAULT](@ref GLFW_WIN32_SHOWDEFAULT_hint) window -hint for applying the show command in the program's `STARTUPINFO` when showing the window -for the first time. This may be useful for the main window of a windowed-mode tool. - - -#### Wayland libdecor decorations {#wayland_libdecor_34} - -GLFW now supports improved fallback window decorations via -[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor). - -Support for libdecor can be toggled before GLFW is initialized with the -[GLFW_WAYLAND_LIBDECOR](@ref GLFW_WAYLAND_LIBDECOR_hint) init hint. It is -enabled by default. - - -#### Window hint for Wayland app_id {#wayland_app_id_34} - -GLFW now supports specifying the app_id for a Wayland window using the -[GLFW_WAYLAND_APP_ID](@ref GLFW_WAYLAND_APP_ID_hint) window hint string. - - -#### Support for ANGLE rendering backend selection {#features_34_angle_backend} +### ANGLE rendering backend hint {#angle_renderer_hint} GLFW now provides the [GLFW_ANGLE_PLATFORM_TYPE](@ref GLFW_ANGLE_PLATFORM_TYPE_hint) init hint for @@ -141,9 +102,59 @@ contexts. [ANGLE]: https://chromium.googlesource.com/angle/angle/ -### Caveats for version 3.4 {#caveats} +### Windows window menu keyboard access hint {#win32_keymenu_hint} -#### Multiple sets of native access functions {#native_34} +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. + + +### Windows STARTUPINFO show command hint {#win32_showdefault_hint} + +GLFW now provides the [GLFW_WIN32_SHOWDEFAULT](@ref GLFW_WIN32_SHOWDEFAULT_hint) window +hint for applying the show command in the program's `STARTUPINFO` when showing the window +for the first time. This may be useful for the main window of a windowed-mode tool. + + +### Cocoa NSView native access function {#cocoa_nsview_function} + +GLFW now provides the @ref glfwGetCocoaView native access function +for returning the Cocoa NSView. + + +### Wayland libdecor decorations {#wayland_libdecor_decorations} + +GLFW now supports improved client-side window decorations via +[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor). This provides +fully featured window decorations on desktop environments like GNOME. + +Support for libdecor can be toggled before GLFW is initialized with the +[GLFW_WAYLAND_LIBDECOR](@ref GLFW_WAYLAND_LIBDECOR_hint) init hint. It is +enabled by default. + +This feature has also been available in GLFW 3.3 since 3.3.9. + + +### Wayland surface app_id hint {#wayland_app_id_hint} + +GLFW now supports specifying the app_id for a Wayland window using the +[GLFW_WAYLAND_APP_ID](@ref GLFW_WAYLAND_APP_ID_hint) window hint string. + + +### X11 Vulkan window surface hint {#x11_xcb_vulkan_surface} + +GLFW now supports disabling the use of `VK_KHR_xcb_surface` over +`VK_KHR_xlib_surface` where available, with the +[GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init hint. +This affects @ref glfwGetRequiredInstanceExtensions and @ref +glfwCreateWindowSurface. + + +## Caveats {#caveats} + +### Multiple sets of native access functions {#multiplatform_caveat} Because GLFW now supports runtime selection of platform (window system), a library binary may export native access functions for multiple platforms. Starting with version 3.4 you @@ -152,47 +163,40 @@ functions for it. After initialization, you can query the selected platform wit glfwGetPlatform. -#### Version string format has been changed {#version_string_34} +### Version string format has been changed {#version_string_caveat} Because GLFW now supports runtime selection of platform (window system), the version string returned by @ref glfwGetVersionString has been expanded. It now contains the names of all APIs for all the platforms that the library binary supports. +The version string is intended for bug reporting and should not be parsed. See +@ref glfwGetVersion and @ref glfwPlatformSupported instead. -#### Joystick support is initialized on demand {#joysticks_34} + +### Joystick support is initialized on demand {#joystick_init_caveat} The joystick part of GLFW is now initialized when first used, primarily to work around faulty Windows drivers that cause DirectInput to take up to several seconds to enumerate devices. -This change will usually not be observable. However, if your application waits -for events without having first called any joystick function or created any -visible windows, the wait may never unblock as GLFW may not yet have subscribed -to joystick related OS events. +This change is mostly not observable. However, if your application waits for +events without having first called any joystick function or created any visible +windows, the wait may never unblock as GLFW may not yet have subscribed to +joystick related OS events. To work around this, call any joystick function before waiting for events, for example by setting a [joystick callback](@ref joystick_event). -#### Framebuffer may lack alpha channel on older Wayland systems {#wayland_alpha_34} +### Tests and examples are disabled when built as a subproject {#standalone_caveat} -On Wayland, when creating an EGL context on a machine lacking the new -`EGL_EXT_present_opaque` extension, the @ref GLFW_ALPHA_BITS window hint will be -ignored and the framebuffer will have no alpha channel. This is because some -Wayland compositors treat any buffer with an alpha channel as per-pixel -transparent. +GLFW now by default does not build the tests or examples when it is added as +a subdirectory of another CMake project. If you were setting @ref +GLFW_BUILD_TESTS or @ref GLFW_BUILD_EXAMPLES to false in your CMake files, you +can now remove this. -If you want a per-pixel transparent window, see the -[GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) window -hint. - - -#### Tests and examples are disabled when built as a subproject {#standalone_34} - -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. +If you do want these to be built, set @ref GLFW_BUILD_TESTS and @ref +GLFW_BUILD_EXAMPLES in your CMake files before adding the GLFW subdirectory. ```cmake set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE) @@ -201,37 +205,86 @@ add_subdirectory(path/to/glfw) ``` -#### macOS main menu now created at initialization {#initmenu_34} +### Configuration header is no longer generated {#config_header_caveat} + +The `glfw_config.h` configuration header is no longer generated by CMake and the +platform selection macros are now part of the GLFW CMake target. The +`_GLFW_USE_CONFIG_H` macro is still supported in case you are generating +a configuration header in a custom build setup. + + +### Documentation generation requires Doxygen 1.9.8 or later {#docs_target_caveat} + +Doxygen 1.9.8 or later is now required for the `docs` CMake target to be +generated. This is because the documentation now uses more of the Markdown +support in Doxygen and this support has until recently been relatively unstable. + + +### Windows 7 framebuffer transparency requires DWM transparency {#win7_framebuffer_caveat} + +GLFW no longer supports per-pixel framebuffer transparency via @ref +GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off +(the Transparency setting under Personalization > Window Color). + + +### macOS main menu now created at initialization {#macos_menu_caveat} 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. -#### CoreVideo dependency has been removed {#corevideo_34} +### macOS CoreVideo dependency has been removed {#corevideo_caveat} GLFW no longer depends on the CoreVideo framework on macOS and it no longer needs to be specified during compilation or linking. -#### Framebuffer transparency requires DWM transparency {#caveat_fbtransparency_34} +### Wayland framebuffer may lack alpha channel on older systems {#wayland_alpha_caveat} -GLFW no longer supports framebuffer transparency enabled via @ref -GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off -(the Transparency setting under Personalization > Window Color). +On Wayland, when creating an EGL context on a machine lacking the new +`EGL_EXT_present_opaque` extension, the @ref GLFW_ALPHA_BITS window hint will be +ignored and the framebuffer will not have an alpha channel. This is because +some Wayland compositors treat any buffer with an alpha channel as per-pixel +transparent. + +If you want a per-pixel transparent window, see the +[GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) window +hint. -#### Empty events on X11 no longer round-trip to server {#emptyevents_34} +### X11 empty events no longer round-trip to server {#x11_emptyevent_caveat} Events posted with @ref glfwPostEmptyEvent now use a separate unnamed pipe instead of sending an X11 client event to the helper window. -### Deprecations in version 3.4 {#deprecations_34} +## Deprecations {#deprecations} -### Removals in 3.4 {#removals_34} +### Windows XP and Vista support is deprecated {#winxp_deprecated} -#### GLFW_VULKAN_STATIC CMake option has been removed {#vulkan_static_34} +Support for Windows XP and Vista has been deprecated and will be removed in +a future release. Windows XP has been out of extended support since 2014. + + +### Original MinGW support is deprecated {#mingw_deprecated} + +Support for the now unmaintained original MinGW distribution has been deprecated +and will be removed in a future release. + +This does not apply to the much more capable MinGW-w64, which remains fully +supported, actively maintained and available on many platforms. + + +### OS X Yosemite support is deprecated {#yosemite_deprecated} + +Support for OS X 10.10 Yosemite and earlier has been deprecated and will be +removed in a future release. OS X 10.10 has been out of support since 2017. + + +## Removals {#removals} + +### GLFW_VULKAN_STATIC CMake option has been removed {#vulkan_static_removed} This option was used to compile GLFW directly linked with the Vulkan loader, instead of using dynamic loading to get hold of `vkGetInstanceProcAddr` at initialization. This is @@ -242,28 +295,43 @@ have no effect. The call to @ref glfwInitVulkanLoader can be conditionally enab your code by checking the @ref GLFW_VERSION_MAJOR and @ref GLFW_VERSION_MINOR macros. -#### GLFW_USE_OSMESA CMake option has been removed {#osmesa_option_34} +### GLFW_USE_WAYLAND CMake option has been removed {#use_wayland_removed} -This option was used to compile GLFW for the Null platform. The Null platform is now -always supported. To produce a library binary that only supports this platform, the way -this CMake option used to do, you will instead need to disable the default platform for -the target OS. This means setting the @ref GLFW_BUILD_WIN32, @ref GLFW_BUILD_COCOA or -@ref GLFW_BUILD_X11 CMake option to false. +This option was used to compile GLFW for Wayland instead of X11. GLFW now +supports selecting the platform at run-time. By default GLFW is compiled for +both Wayland and X11 on Linux and other Unix-like systems. -You can set all of them to false and the ones that don't apply for the target OS will be -ignored. +To disable Wayland or X11 or both, set the @ref GLFW_BUILD_WAYLAND and @ref +GLFW_BUILD_X11 CMake options. + +The `GLFW_USE_WAYLAND` CMake variable must not be present in the CMake cache at +all, or GLFW will fail to configure. If you are getting this error, delete the +CMake cache for GLFW and configure again. -#### Support for the wl_shell protocol has been removed {#wl_shell_34} +### GLFW_USE_OSMESA CMake option has been removed {#use_osmesa_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. +This option was used to compile GLFW for the Null platform. The Null platform +is now always available. To produce a library binary that only supports this +platform, the way this CMake option used to do, you will instead need to disable +the default platforms for the target OS. This means setting the @ref +GLFW_BUILD_WIN32, @ref GLFW_BUILD_COCOA or @ref GLFW_BUILD_WAYLAND and @ref +GLFW_BUILD_X11 CMake options to false. + +You can set all of them to false and the ones that don't apply for the target OS +will be ignored. -### New symbols in version 3.4 {#symbols_34} +### wl_shell protocol support has been removed {#wl_shell_removed} -#### New functions in version 3.4 {#functions_34} +Support for the deprecated 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. + + +## New symbols {#new_symbols} + +### New functions {#new_functions} - @ref glfwInitAllocator - @ref glfwGetPlatform @@ -273,7 +341,7 @@ then GLFW will fail to initialize. - @ref glfwGetCocoaView -#### New types in version 3.4 {#types_34} +### New types {#new_types} - @ref GLFWallocator - @ref GLFWallocatefun @@ -281,7 +349,7 @@ then GLFW will fail to initialize. - @ref GLFWdeallocatefun -#### New constants in version 3.4 {#constants_34} +### New constants {#new_constants} - @ref GLFW_PLATFORM - @ref GLFW_ANY_PLATFORM From d24ee9953f49c0554ebff09c063e0212a2bfc5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 29 Feb 2024 15:28:46 +0100 Subject: [PATCH 121/137] Start 3.5 --- .gitignore | 4 +- CMakeLists.txt | 2 +- README.md | 321 +------------------------------ docs/build.md | 2 +- docs/intro.md | 6 +- docs/news.md | 377 +------------------------------------ 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_time.h | 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/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.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/platform.c | 2 +- src/platform.h | 2 +- src/posix_module.c | 2 +- src/posix_poll.c | 2 +- src/posix_poll.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/win32_init.c | 2 +- src/win32_joystick.c | 2 +- src/win32_joystick.h | 2 +- src/win32_module.c | 2 +- src/win32_monitor.c | 2 +- src/win32_platform.h | 2 +- src/win32_thread.c | 2 +- src/win32_thread.h | 2 +- src/win32_time.c | 2 +- src/win32_time.h | 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 +- 68 files changed, 73 insertions(+), 765 deletions(-) diff --git a/.gitignore b/.gitignore index 9d2d504b..8ed24d98 100644 --- a/.gitignore +++ b/.gitignore @@ -57,11 +57,11 @@ src/glfw3ConfigVersion.cmake # Compiled binaries src/libglfw.so src/libglfw.so.3 -src/libglfw.so.3.4 +src/libglfw.so.3.5 src/libglfw.dylib src/libglfw.dylib src/libglfw.3.dylib -src/libglfw.3.4.dylib +src/libglfw.3.5.dylib src/libglfw3.a src/glfw3.lib src/glfw3.dll diff --git a/CMakeLists.txt b/CMakeLists.txt index a3cb1fe6..830f8fd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR) -project(GLFW VERSION 3.4.0 LANGUAGES C) +project(GLFW VERSION 3.5.0 LANGUAGES C) if (POLICY CMP0069) cmake_policy(SET CMP0069 NEW) diff --git a/README.md b/README.md index efd1383f..876eefa7 100644 --- a/README.md +++ b/README.md @@ -119,326 +119,7 @@ guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for information on what to include when reporting a bug. -## Changelog since 3.3.10 - - - Added `GLFW_PLATFORM` init hint for runtime platform selection (#1958) - - Added `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, - `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` and `GLFW_PLATFORM_NULL` symbols to - specify the desired platform (#1958) - - Added `glfwGetPlatform` function to query what platform was selected (#1655,#1958) - - Added `glfwPlatformSupported` function to query if a platform is supported - (#1655,#1958) - - Added `glfwInitAllocator` for setting a custom memory allocator (#544,#1628,#1947) - - Added `GLFWallocator` struct and `GLFWallocatefun`, `GLFWreallocatefun` and - `GLFWdeallocatefun` types (#544,#1628,#1947) - - Added `glfwGetWindowTitle` function for querying window title (#1448,#1909,#2482) - - Added `glfwInitVulkanLoader` for using a non-default Vulkan loader (#1374,#1890) - - 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) - - Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass - through the window (#1236,#1568) - - Added `GLFW_CURSOR_CAPTURED` cursor mode to confine the cursor to the window - content area (#58) - - Added `GLFW_POSITION_X` and `GLFW_POSITION_Y` window hints for initial position - (#1603,#1747) - - Added `GLFW_SCALE_FRAMEBUFFER` window hint for Wayland and macOS scaling (#2457) - - Added `GLFW_ANY_POSITION` hint value for letting the window manager choose (#1603,#1747) - - Added `GLFW_PLATFORM_UNAVAILABLE` error for platform detection failures (#1958) - - Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692) - - Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692) - - Added `GLFW_WAYLAND_APP_ID` window hint string for Wayland app\_id selection - (#2121,#2122) - - Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*` - values to select ANGLE backend (#1380) - - Added `GLFW_X11_XCB_VULKAN_SURFACE` init hint for selecting X11 Vulkan - surface extension (#1793) - - Added `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access to the window menu - - Added `GLFW_WIN32_SHOWDEFAULT` window hint for applying the parent process - show command (#2359) - - Added `GLFW_NATIVE_INCLUDE_NONE` for disabling inclusion of native headers (#1348) - - Added `GLFW_BUILD_WIN32` CMake option for enabling Win32 support (#1958) - - Added `GLFW_BUILD_COCOA` CMake option for enabling Cocoa support (#1958) - - Added `GLFW_BUILD_X11` CMake option for enabling X11 support (#1958) - - Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type - (#279,#1307,#1497,#1574,#1928) - - Added support for `XDG_SESSION_TYPE` environment variable - - Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake - variables exposing pkg-config dependencies (#1307) - - Made joystick subsystem initialize at first use (#1284,#1646) - - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - - Made Wayland the preferred platform over X11 if both are available (#2035) - - Updated the minimum required CMake version to 3.4 - - Updated gamepad mappings from upstream - - Renamed `GLFW_USE_WAYLAND` CMake option to `GLFW_BUILD_WAYLAND` (#1958) - - Disabled tests and examples by default when built as a CMake subdirectory - - Removed `GLFW_USE_OSMESA` CMake option enabling the Null platform (#1958) - - Removed CMake generated configuration header - - Bugfix: `glfwGetVideoMode` returned an invalid mode on error (#1292) - - [Win32] Added a version info resource to the GLFW DLL - - [Win32] Made hidden helper window use its own window class - - [Win32] Bugfix: The foreground lock timeout was overridden, ignoring the user - - [Cocoa] Added `glfwGetCocoaView` native access function (#2235) - - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) - - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread - would abort (#1649) - - [Wayland] Added support for `glfwRequestWindowAttention` (#2287) - - [Wayland] Added support for `glfwFocusWindow` - - [Wayland] Added support for `GLFW_RESIZABLE` (#2203) - - [Wayland] Added support for fractional scaling of window contents - - [Wayland] Added dynamic loading of all Wayland libraries - - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled - - [Wayland] Bugfix: `GLFW_HOVERED` was true when the cursor was over any - fallback window decoration - - [Wayland] Bugfix: Fallback decorations allowed resizing to invalid size - (#2204) - - [X11] Bugfix: Termination would segfault if the IM had been destroyed - - [X11] Bugfix: Any IM started after initialization would not be detected - - [Linux] Bugfix: Joystick evdev fds remained open in forks (#2446) - - [POSIX] Removed use of deprecated function `gettimeofday` - - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - - [WGL] Disabled the DWM swap interval hack for Windows 8 and later (#1072) - - [NSGL] Removed enforcement of forward-compatible flag for core contexts - - [NSGL] Bugfix: A core profile OpenGL context was returned if 3.2+ - compatibility profile was requested - - [EGL] Added platform selection via the `EGL_EXT_platform_base` extension - (#442) - - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension - (#1380) - - -## Changelog since 3.3 - - - Added `GLFW_WAYLAND_LIBDECOR` init hint for disabling libdecor support (#1639,#1693) - - Bugfix: The CMake config-file package used an absolute path and was not - relocatable (#1470) - - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) - - Bugfix: Compiling with -Wextra-semi caused warnings (#1440) - - Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583) - - Bugfix: Some extension loader headers did not prevent default OpenGL header - inclusion (#1695) - - Bugfix: Buffers were swapped at creation on single-buffered windows (#1873) - - Bugfix: Gamepad mapping updates could spam `GLFW_INVALID_VALUE` due to - incompatible controllers sharing hardware ID (#1763) - - Bugfix: Native access functions for context handles did not check that the API matched - - Bugfix: `glfwMakeContextCurrent` would access TLS slot before initialization - - Bugfix: `glfwSetGammaRamp` could emit `GLFW_INVALID_VALUE` before initialization - - Bugfix: `glfwGetJoystickUserPointer` returned `NULL` during disconnection (#2092) - - Bugfix: `glfwGetKeyScancode` returned `0` on error when initialized instead of `-1` - - Bugfix: Failure to make a newly created context current could cause segfault (#2327) - - [Win32] Disabled framebuffer transparency on Windows 7 when DWM windows are - opaque (#1512) - - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused - symbol redefinition (#1524) - - [Win32] Bugfix: The cursor position event was emitted before its cursor enter - event (#1490) - - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the - window (#1499) - - [Win32] Bugfix: Disabled cursor mode interfered with some non-client actions - - [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) - - [Win32] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16 - - [Win32] Bugfix: Monitor functions could return invalid values after - configuration change (#1761) - - [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775) - - [Win32] Bugfix: Duplicate size events were not filtered (#1610) - - [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes - (#1582) - - [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than - Windows 10 version 1703 (#1511) - - [Win32] Bugfix: `USE_MSVC_RUNTIME_LIBRARY_DLL` had no effect on CMake 3.15 or - later (#1783,#1796) - - [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874) - - [Win32] Bugfix: Content scale queries could fail silently (#1615) - - [Win32] Bugfix: Content scales could have garbage values if monitor was recently - disconnected (#1615) - - [Win32] Bugfix: A window created maximized and undecorated would cover the whole - monitor (#1806) - - [Win32] Bugfix: The default restored window position was lost when creating a maximized - window - - [Win32] Bugfix: `glfwMaximizeWindow` would make a hidden window visible - - [Win32] Bugfix: `Alt+PrtSc` would emit `GLFW_KEY_UNKNOWN` and a different - scancode than `PrtSc` (#1993) - - [Win32] Bugfix: `GLFW_KEY_PAUSE` scancode from `glfwGetKeyScancode` did not - match event scancode (#1993) - - [Win32] Bugfix: Instance-local operations used executable instance (#469,#1296,#1395) - - [Win32] Bugfix: The OSMesa library was not unloaded on termination - - [Win32] Bugfix: Right shift emitted `GLFW_KEY_UNKNOWN` when using a CJK IME (#2050) - - [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408) - - [Win32] Bugfix: Fix pkg-config for dynamic library on Windows (#2386, #2420) - - [Win32] Bugfix: XInput could reportedly provide invalid DPad bit masks (#2291) - - [Win32] Bugfix: Rapid clipboard calls could fail due to Clipboard History - - [Win32] Bugfix: Disabled cursor mode doesn't work right when connected over RDP (#1276,#1279,#2431) - - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - - [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169) - - [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency - (#1786) - - [Cocoa] Disabled macOS fullscreen when `GLFW_RESIZABLE` is false - - [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: Non-BMP Unicode codepoint input was reported as UTF-16 - (#1635) - - [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays - could leak memory - - [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787) - - [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830) - - [Cocoa] Bugfix: Menu bar was not clickable on macOS 10.15+ until it lost and - regained focus (#1648,#1802) - - [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833) - - [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504) - - [Cocoa] Bugfix: The MoltenVK layer contents scale was updated only after - related events were emitted - - [Cocoa] Bugfix: Moving the cursor programmatically would freeze it for - a fraction of a second (#1962) - - [Cocoa] Bugfix: `kIOMasterPortDefault` was deprecated in macOS 12.0 (#1980) - - [Cocoa] Bugfix: `kUTTypeURL` was deprecated in macOS 12.0 (#2003) - - [Cocoa] Bugfix: A connected Apple AirPlay would emit a useless error (#1791) - - [Cocoa] Bugfix: The EGL and OSMesa libraries were not unloaded on termination - - [Cocoa] Bugfix: `GLFW_MAXIMIZED` was always true when `GLFW_RESIZABLE` was false - - [Cocoa] Bugfix: Changing `GLFW_DECORATED` in macOS fullscreen would abort - application (#1886) - - [Cocoa] Bugfix: Setting a monitor from macOS fullscreen would abort - application (#2110) - - [Cocoa] Bugfix: The Vulkan loader was not loaded from the `Frameworks` bundle - subdirectory (#2113,#2120) - - [Cocoa] Bugfix: Compilation failed on OS X 10.8 due to unconditional use of 10.9+ - symbols (#2161) - - [Cocoa] Bugfix: Querying joystick elements could reportedly segfault on macOS - 13 Ventura (#2320) - - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480) - - [X11] Bugfix: Key names were not updated when the keyboard layout changed - (#1462,#1528) - - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) - - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) - - [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows - - [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read - - [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail - - [X11] Bugfix: Disabled cursor mode was interrupted by indicator windows - - [X11] Bugfix: Monitor physical dimensions could be reported as zero mm - - [X11] Bugfix: Window position events were not emitted during resizing (#1613) - - [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: 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 - combinations (#1598) - - [X11] Bugfix: Keys pressed simultaneously with others were not always - reported (#1112,#1415,#1472,#1616) - - [X11] Bugfix: Some window attributes were not applied on leaving fullscreen - (#1863) - - [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory - - [X11] Bugfix: Icon pixel format conversion worked only by accident, relying on - undefined behavior (#1986) - - [X11] Bugfix: Dynamic loading on OpenBSD failed due to soname differences - - [X11] Bugfix: Waiting for events would fail if file descriptor was too large - (#2024) - - [X11] Bugfix: Joystick events could lead to busy-waiting (#1872) - - [X11] Bugfix: `glfwWaitEvents*` did not continue for joystick events - - [X11] Bugfix: `glfwPostEmptyEvent` could be ignored due to race condition - (#379,#1281,#1285,#2033) - - [X11] Bugfix: Dynamic loading on NetBSD failed due to soname differences - - [X11] Bugfix: Left shift of int constant relied on undefined behavior (#1951) - - [X11] Bugfix: The OSMesa libray was not unloaded on termination - - [X11] Bugfix: A malformed response during selection transfer could cause a segfault - - [X11] Bugfix: Some calls would reset Xlib to the default error handler (#2108) - - [Wayland] Added improved fallback window decorations via libdecor (#1639,#1693) - - [Wayland] Added support for key names via xkbcommon - - [Wayland] Added support for file path drop events (#2040) - - [Wayland] Added support for more human-readable monitor names where available - - [Wayland] Disabled alpha channel for opaque windows on systems lacking - `EGL_EXT_present_opaque` (#1895) - - [Wayland] Removed support for `wl_shell` (#1443) - - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - - [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704) - - [Wayland] Bugfix: Retrieving partial framebuffer size would segfault - - [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms - (#1463) - - [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong order - (#1798) - - [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792) - - [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908) - - [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899) - - [Wayland] Bugfix: The `O_CLOEXEC` flag was not defined on FreeBSD - - [Wayland] Bugfix: Key repeat could lead to a race condition (#1710) - - [Wayland] Bugfix: Activating a window would emit two input focus events - - [Wayland] Bugfix: Disable key repeat mechanism when window loses input focus - - [Wayland] Bugfix: Window hiding and showing did not work (#1492,#1731) - - [Wayland] Bugfix: A key being repeated was not released when window lost focus - - [Wayland] Bugfix: Showing a hidden window did not emit a window refresh event - - [Wayland] Bugfix: Full screen window creation did not ignore `GLFW_VISIBLE` - - [Wayland] Bugfix: Some keys were reported as wrong key or `GLFW_KEY_UNKNOWN` - - [Wayland] Bugfix: Text input did not repeat along with key repeat - - [Wayland] Bugfix: `glfwPostEmptyEvent` sometimes had no effect (#1520,#1521) - - [Wayland] Bugfix: `glfwSetClipboardString` would fail if set to result of - `glfwGetClipboardString` - - [Wayland] Bugfix: Data source creation error would cause double free at termination - - [Wayland] Bugfix: Partial writes of clipboard string would cause beginning to repeat - - [Wayland] Bugfix: Some errors would cause clipboard string transfer to hang - - [Wayland] Bugfix: Drag and drop data was misinterpreted as clipboard string - - [Wayland] Bugfix: MIME type matching was not performed for clipboard string - - [Wayland] Bugfix: The OSMesa library was not unloaded on termination - - [Wayland] Bugfix: `glfwCreateWindow` could emit `GLFW_FEATURE_UNAVAILABLE` - - [Wayland] Bugfix: Lock key modifier bits were only set when lock keys were pressed - - [Wayland] Bugfix: A window leaving full screen mode would be iconified (#1995) - - [Wayland] Bugfix: A window leaving full screen mode ignored its desired size - - [Wayland] Bugfix: `glfwSetWindowMonitor` did not update windowed mode size - - [Wayland] Bugfix: `glfwRestoreWindow` would make a full screen window windowed - - [Wayland] Bugfix: A window maximized or restored by the user would enter an - inconsistent state - - [Wayland] Bugfix: Window maximization events were not emitted - - [Wayland] Bugfix: `glfwRestoreWindow` assumed it was always in windowed mode - - [Wayland] Bugfix: `glfwSetWindowSize` would resize a full screen window - - [Wayland] Bugfix: A window content scale event would be emitted every time - the window resized - - [Wayland] Bugfix: If `glfwInit` failed it would close stdin - - [Wayland] Bugfix: Manual resizing with fallback decorations behaved erratically - (#1991,#2115,#2127) - - [Wayland] Bugfix: Size limits included frame size for fallback decorations - - [Wayland] Bugfix: Updating `GLFW_DECORATED` had no effect on server-side - decorations - - [Wayland] Bugfix: A monitor would be reported as connected again if its scale - changed - - [Wayland] Bugfix: `glfwTerminate` would segfault if any monitor had changed - scale - - [Wayland] Bugfix: Window content scale events were not emitted when monitor - scale changed - - [Wayland] Bugfix: `glfwSetWindowAspectRatio` reported an error instead of - applying the specified ratio - - [Wayland] Bugfix: `GLFW_MAXIMIZED` window hint had no effect - - [Wayland] Bugfix: `glfwRestoreWindow` had no effect before first show - - [Wayland] Bugfix: Hiding and then showing a window caused program abort on - wlroots compositors (#1268) - - [Wayland] Bugfix: `GLFW_DECORATED` was ignored when showing a window with XDG - decorations - - [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450) - - [Wayland] Bugfix: Joysticks connected after `glfwInit` were not detected (#2198) - - [Wayland] Bugfix: Fallback decorations emitted `GLFW_CURSOR_UNAVAILABLE` errors - - [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043) - - [Linux] Bugfix: A small amount of memory could leak if initialization failed (#2229) - - [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) - - [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused - a duplicate definition warning (#1840) - - [EGL] Added loading of glvnd `libOpenGL.so.0` where available for OpenGL - - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) - - [EGL] Bugfix: Setting `GLFW_CONTEXT_DEBUG` caused creation to fail (#2348) - - [GLX] Added loading of glvnd `libGLX.so.0` where available - - [GLX] Bugfix: Context creation failed if GLX 1.4 was not exported by GLX library +## Changelog since 3.4 ## Contact diff --git a/docs/build.md b/docs/build.md index d00d676e..ab4b6817 100644 --- a/docs/build.md +++ b/docs/build.md @@ -310,7 +310,7 @@ With a few changes to your `CMakeLists.txt` you can locate the package and target files generated when GLFW is installed. ```cmake -find_package(glfw3 3.4 REQUIRED) +find_package(glfw3 3.5 REQUIRED) ``` Once GLFW has been added to the project, link against it with the `glfw` target. diff --git a/docs/intro.md b/docs/intro.md index 0610202f..7aa75e31 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -621,17 +621,17 @@ The format of the string is as follows: - The names of the always supported context creation APIs EGL and OSMesa - Any additional compile-time options, APIs and (on Windows) what compiler was used -For example, compiling GLFW 3.4 with MinGW as a DLL for Windows, may result in a version string +For example, compiling GLFW 3.5 with MinGW as a DLL for Windows, may result in a version string like this: ```c -3.4.0 Win32 WGL Null EGL OSMesa MinGW DLL +3.5.0 Win32 WGL Null EGL OSMesa MinGW DLL ``` Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may result in a version string like this: ```c -3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic +3.5.0 Wayland X11 GLX Null EGL OSMesa monotonic ``` diff --git a/docs/news.md b/docs/news.md index 3be95488..fd93a712 100644 --- a/docs/news.md +++ b/docs/news.md @@ -1,400 +1,27 @@ -# Release notes for version 3.4 {#news} +# Release notes for version 3.5 {#news} [TOC] ## New features {#features} -### Runtime platform selection {#runtime_platform_selection} - -GLFW now supports being compiled for multiple backends and selecting between -them at runtime with the @ref GLFW_PLATFORM init hint. After initialization the -selected platform can be queried with @ref glfwGetPlatform. You can check if -support for a given platform is compiled in with @ref glfwPlatformSupported. - -For more information see @ref platform. - - -### More standard cursor shapes {#more_cursor_shapes} - -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 omnidirectional 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. - - -### Mouse event passthrough {#mouse_input_passthrough} - -GLFW now provides the [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint) -window hint for making a window transparent to mouse input, lettings events pass -to whatever window is behind it. This can also be changed after window -creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib). - - -### Ability to get window title {#window_title_function} - -GLFW now supports querying the title of a window with the @ref glfwGetWindowTitle -function. - -For more information see @ref window_title. - - -### Captured cursor mode {#captured_cursor_mode} - -GLFW now supports confining the cursor to the window content area with the @ref -GLFW_CURSOR_CAPTURED cursor mode. - -For more information see @ref cursor_mode. - - -### Support for custom heap memory allocator {#custom_heap_allocator} - -GLFW now supports plugging a custom heap memory allocator at initialization with -@ref glfwInitAllocator. The allocator is a struct of type @ref GLFWallocator -with function pointers corresponding to the standard library functions `malloc`, -`realloc` and `free`. - -For more information see @ref init_allocator. - - -### Window hint for framebuffer scaling {#scale_framebuffer_hint} - -GLFW now allows provides the -[GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for -controlling framebuffer scaling on platforms that handle scaling by keeping the -window size the same while resizing the framebuffer. The default value is to -allow framebuffer scaling. - -This was already possible on macOS via the -[GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) window -hint. This is now another name for the same hint value. - -For more information see @ref window_scale. - - -### Window hints for initial window position {#window_position_hint} - -GLFW now provides the @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints for -specifying the initial position of the window. This removes the need to create a hidden -window, move it and then show it. The default value of these hints is -`GLFW_ANY_POSITION`, which selects the previous behavior. - -For more information see @ref window_pos. - - -### ANGLE rendering backend hint {#angle_renderer_hint} - -GLFW now provides the -[GLFW_ANGLE_PLATFORM_TYPE](@ref GLFW_ANGLE_PLATFORM_TYPE_hint) init hint for -requesting a specific rendering backend when using [ANGLE][] to create OpenGL ES -contexts. - -[ANGLE]: https://chromium.googlesource.com/angle/angle/ - - -### Windows window menu keyboard access hint {#win32_keymenu_hint} - -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. - - -### Windows STARTUPINFO show command hint {#win32_showdefault_hint} - -GLFW now provides the [GLFW_WIN32_SHOWDEFAULT](@ref GLFW_WIN32_SHOWDEFAULT_hint) window -hint for applying the show command in the program's `STARTUPINFO` when showing the window -for the first time. This may be useful for the main window of a windowed-mode tool. - - -### Cocoa NSView native access function {#cocoa_nsview_function} - -GLFW now provides the @ref glfwGetCocoaView native access function -for returning the Cocoa NSView. - - -### Wayland libdecor decorations {#wayland_libdecor_decorations} - -GLFW now supports improved client-side window decorations via -[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor). This provides -fully featured window decorations on desktop environments like GNOME. - -Support for libdecor can be toggled before GLFW is initialized with the -[GLFW_WAYLAND_LIBDECOR](@ref GLFW_WAYLAND_LIBDECOR_hint) init hint. It is -enabled by default. - -This feature has also been available in GLFW 3.3 since 3.3.9. - - -### Wayland surface app_id hint {#wayland_app_id_hint} - -GLFW now supports specifying the app_id for a Wayland window using the -[GLFW_WAYLAND_APP_ID](@ref GLFW_WAYLAND_APP_ID_hint) window hint string. - - -### X11 Vulkan window surface hint {#x11_xcb_vulkan_surface} - -GLFW now supports disabling the use of `VK_KHR_xcb_surface` over -`VK_KHR_xlib_surface` where available, with the -[GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init hint. -This affects @ref glfwGetRequiredInstanceExtensions and @ref -glfwCreateWindowSurface. - - ## Caveats {#caveats} -### Multiple sets of native access functions {#multiplatform_caveat} - -Because GLFW now supports runtime selection of platform (window system), a library binary -may export native access functions for multiple platforms. Starting with version 3.4 you -must not assume that GLFW is running on a platform just because it exports native access -functions for it. After initialization, you can query the selected platform with @ref -glfwGetPlatform. - - -### Version string format has been changed {#version_string_caveat} - -Because GLFW now supports runtime selection of platform (window system), the version -string returned by @ref glfwGetVersionString has been expanded. It now contains the names -of all APIs for all the platforms that the library binary supports. - -The version string is intended for bug reporting and should not be parsed. See -@ref glfwGetVersion and @ref glfwPlatformSupported instead. - - -### Joystick support is initialized on demand {#joystick_init_caveat} - -The joystick part of GLFW is now initialized when first used, primarily to work -around faulty Windows drivers that cause DirectInput to take up to several -seconds to enumerate devices. - -This change is mostly not observable. However, if your application waits for -events without having first called any joystick function or created any visible -windows, the wait may never unblock as GLFW may not yet have subscribed to -joystick related OS events. - -To work around this, call any joystick function before waiting for events, for -example by setting a [joystick callback](@ref joystick_event). - - -### Tests and examples are disabled when built as a subproject {#standalone_caveat} - -GLFW now by default does not build the tests or examples when it is added as -a subdirectory of another CMake project. If you were setting @ref -GLFW_BUILD_TESTS or @ref GLFW_BUILD_EXAMPLES to false in your CMake files, you -can now remove this. - -If you do want these to be built, set @ref GLFW_BUILD_TESTS and @ref -GLFW_BUILD_EXAMPLES in your CMake files before adding the GLFW subdirectory. - -```cmake -set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE) -set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE) -add_subdirectory(path/to/glfw) -``` - - -### Configuration header is no longer generated {#config_header_caveat} - -The `glfw_config.h` configuration header is no longer generated by CMake and the -platform selection macros are now part of the GLFW CMake target. The -`_GLFW_USE_CONFIG_H` macro is still supported in case you are generating -a configuration header in a custom build setup. - - -### Documentation generation requires Doxygen 1.9.8 or later {#docs_target_caveat} - -Doxygen 1.9.8 or later is now required for the `docs` CMake target to be -generated. This is because the documentation now uses more of the Markdown -support in Doxygen and this support has until recently been relatively unstable. - - -### Windows 7 framebuffer transparency requires DWM transparency {#win7_framebuffer_caveat} - -GLFW no longer supports per-pixel framebuffer transparency via @ref -GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off -(the Transparency setting under Personalization > Window Color). - - -### macOS main menu now created at initialization {#macos_menu_caveat} - -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. - - -### macOS CoreVideo dependency has been removed {#corevideo_caveat} - -GLFW no longer depends on the CoreVideo framework on macOS and it no longer -needs to be specified during compilation or linking. - - -### Wayland framebuffer may lack alpha channel on older systems {#wayland_alpha_caveat} - -On Wayland, when creating an EGL context on a machine lacking the new -`EGL_EXT_present_opaque` extension, the @ref GLFW_ALPHA_BITS window hint will be -ignored and the framebuffer will not have an alpha channel. This is because -some Wayland compositors treat any buffer with an alpha channel as per-pixel -transparent. - -If you want a per-pixel transparent window, see the -[GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) window -hint. - - -### X11 empty events no longer round-trip to server {#x11_emptyevent_caveat} - -Events posted with @ref glfwPostEmptyEvent now use a separate unnamed pipe -instead of sending an X11 client event to the helper window. - - ## Deprecations {#deprecations} -### Windows XP and Vista support is deprecated {#winxp_deprecated} - -Support for Windows XP and Vista has been deprecated and will be removed in -a future release. Windows XP has been out of extended support since 2014. - - -### Original MinGW support is deprecated {#mingw_deprecated} - -Support for the now unmaintained original MinGW distribution has been deprecated -and will be removed in a future release. - -This does not apply to the much more capable MinGW-w64, which remains fully -supported, actively maintained and available on many platforms. - - -### OS X Yosemite support is deprecated {#yosemite_deprecated} - -Support for OS X 10.10 Yosemite and earlier has been deprecated and will be -removed in a future release. OS X 10.10 has been out of support since 2017. - - ## Removals {#removals} -### GLFW_VULKAN_STATIC CMake option has been removed {#vulkan_static_removed} - -This option was used to compile GLFW directly linked with the Vulkan loader, instead of -using dynamic loading to get hold of `vkGetInstanceProcAddr` at initialization. This is -now done by calling the @ref glfwInitVulkanLoader function before initialization. - -If you need backward compatibility, this macro can still be defined for GLFW 3.4 and will -have no effect. The call to @ref glfwInitVulkanLoader can be conditionally enabled in -your code by checking the @ref GLFW_VERSION_MAJOR and @ref GLFW_VERSION_MINOR macros. - - -### GLFW_USE_WAYLAND CMake option has been removed {#use_wayland_removed} - -This option was used to compile GLFW for Wayland instead of X11. GLFW now -supports selecting the platform at run-time. By default GLFW is compiled for -both Wayland and X11 on Linux and other Unix-like systems. - -To disable Wayland or X11 or both, set the @ref GLFW_BUILD_WAYLAND and @ref -GLFW_BUILD_X11 CMake options. - -The `GLFW_USE_WAYLAND` CMake variable must not be present in the CMake cache at -all, or GLFW will fail to configure. If you are getting this error, delete the -CMake cache for GLFW and configure again. - - -### GLFW_USE_OSMESA CMake option has been removed {#use_osmesa_removed} - -This option was used to compile GLFW for the Null platform. The Null platform -is now always available. To produce a library binary that only supports this -platform, the way this CMake option used to do, you will instead need to disable -the default platforms for the target OS. This means setting the @ref -GLFW_BUILD_WIN32, @ref GLFW_BUILD_COCOA or @ref GLFW_BUILD_WAYLAND and @ref -GLFW_BUILD_X11 CMake options to false. - -You can set all of them to false and the ones that don't apply for the target OS -will be ignored. - - -### wl_shell protocol support has been removed {#wl_shell_removed} - -Support for the deprecated 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. - - ## New symbols {#new_symbols} ### New functions {#new_functions} - - @ref glfwInitAllocator - - @ref glfwGetPlatform - - @ref glfwPlatformSupported - - @ref glfwInitVulkanLoader - - @ref glfwGetWindowTitle - - @ref glfwGetCocoaView - - ### New types {#new_types} - - @ref GLFWallocator - - @ref GLFWallocatefun - - @ref GLFWreallocatefun - - @ref GLFWdeallocatefun - - ### New constants {#new_constants} - - @ref GLFW_PLATFORM - - @ref GLFW_ANY_PLATFORM - - @ref GLFW_PLATFORM_WIN32 - - @ref GLFW_PLATFORM_COCOA - - @ref GLFW_PLATFORM_WAYLAND - - @ref GLFW_PLATFORM_X11 - - @ref GLFW_PLATFORM_NULL - - @ref GLFW_PLATFORM_UNAVAILABLE - - @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_MOUSE_PASSTHROUGH - - @ref GLFW_NOT_ALLOWED_CURSOR - - @ref GLFW_CURSOR_UNAVAILABLE - - @ref GLFW_WIN32_KEYBOARD_MENU - - @ref GLFW_WIN32_SHOWDEFAULT - - @ref GLFW_CONTEXT_DEBUG - - @ref GLFW_FEATURE_UNAVAILABLE - - @ref GLFW_FEATURE_UNIMPLEMENTED - - @ref GLFW_ANGLE_PLATFORM_TYPE - - @ref GLFW_ANGLE_PLATFORM_TYPE_NONE - - @ref GLFW_ANGLE_PLATFORM_TYPE_OPENGL - - @ref GLFW_ANGLE_PLATFORM_TYPE_OPENGLES - - @ref GLFW_ANGLE_PLATFORM_TYPE_D3D9 - - @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11 - - @ref GLFW_ANGLE_PLATFORM_TYPE_VULKAN - - @ref GLFW_ANGLE_PLATFORM_TYPE_METAL - - @ref GLFW_X11_XCB_VULKAN_SURFACE - - @ref GLFW_CURSOR_CAPTURED - - @ref GLFW_POSITION_X - - @ref GLFW_POSITION_Y - - @ref GLFW_ANY_POSITION - - @ref GLFW_WAYLAND_APP_ID - - @ref GLFW_WAYLAND_LIBDECOR - - @ref GLFW_WAYLAND_PREFER_LIBDECOR - - @ref GLFW_WAYLAND_DISABLE_LIBDECOR - - @ref GLFW_SCALE_FRAMEBUFFER - - ## Release notes for earlier versions {#news_archive} +- [Release notes for 3.4](https://www.glfw.org/docs/3.4/news.html) - [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) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 9c55ac9d..9a6ad6fd 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1,5 +1,5 @@ /************************************************************************* - * GLFW 3.4 - www.glfw.org + * GLFW 3.5 - www.glfw.org * A library for OpenGL, window and input *------------------------------------------------------------------------ * Copyright (c) 2002-2006 Marcus Geelnard @@ -291,7 +291,7 @@ extern "C" { * features are added to the API but it remains backward-compatible. * @ingroup init */ -#define GLFW_VERSION_MINOR 4 +#define GLFW_VERSION_MINOR 5 /*! @brief The revision number of the GLFW header. * * The revision number of the GLFW header. This is incremented when a bug fix diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 92f0d324..011b239c 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -1,5 +1,5 @@ /************************************************************************* - * GLFW 3.4 - www.glfw.org + * GLFW 3.5 - 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 e75a5519..15dc4ec4 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_joystick.h b/src/cocoa_joystick.h index 2f46dfcb..c3a58e23 100644 --- a/src/cocoa_joystick.h +++ b/src/cocoa_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Cocoa - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2017 Camilla Löwy // diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index d5de4793..bb86ad22 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Cocoa - www.glfw.org +// GLFW 3.5 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 641d5f0b..75f8ec53 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 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 39914554..4d1d66ae 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_time.c b/src/cocoa_time.c index d56f145f..a153edb3 100644 --- a/src/cocoa_time.c +++ b/src/cocoa_time.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2016 Camilla Löwy // diff --git a/src/cocoa_time.h b/src/cocoa_time.h index 3512e8b6..8463cbb6 100644 --- a/src/cocoa_time.h +++ b/src/cocoa_time.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2021 Camilla Löwy // diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 0dcf0a38..5fa360dd 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/context.c b/src/context.c index cc1fac4f..7232dc2a 100644 --- a/src/context.c +++ b/src/context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 ef65dd35..06deb76f 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 EGL - www.glfw.org +// GLFW 3.5 EGL - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/glx_context.c b/src/glx_context.c index 7082682b..fae55966 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 GLX - www.glfw.org +// GLFW 3.5 GLX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/init.c b/src/init.c index 532264e1..dbd5a900 100644 --- a/src/init.c +++ b/src/init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 7b3b3402..3f8ddb30 100644 --- a/src/input.c +++ b/src/input.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 88733593..76f3ede2 100644 --- a/src/internal.h +++ b/src/internal.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 07d41d37..d8a916b0 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Linux - www.glfw.org +// GLFW 3.5 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 64462b04..1ea3deb3 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Linux - www.glfw.org +// GLFW 3.5 Linux - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/mappings.h b/src/mappings.h index 270fa4cd..cd32e5d0 100644 --- a/src/mappings.h +++ b/src/mappings.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2018 Camilla Löwy // diff --git a/src/mappings.h.in b/src/mappings.h.in index ed623680..99d18330 100644 --- a/src/mappings.h.in +++ b/src/mappings.h.in @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2018 Camilla Löwy // diff --git a/src/monitor.c b/src/monitor.c index efc286d5..6f802e32 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/nsgl_context.m b/src/nsgl_context.m index daa8367a..d34cc224 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/null_init.c b/src/null_init.c index 88940fcd..8c10f5e6 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 ec1f6b55..16dc8cf3 100644 --- a/src/null_joystick.c +++ b/src/null_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016-2017 Camilla Löwy // diff --git a/src/null_joystick.h b/src/null_joystick.h index a2199c56..40a490f9 100644 --- a/src/null_joystick.h +++ b/src/null_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2017 Camilla Löwy // diff --git a/src/null_monitor.c b/src/null_monitor.c index d818f452..a9b528f0 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 4843a76a..8222b0de 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 1db08114..75326065 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 2f12adf2..0b9d83a2 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 OSMesa - www.glfw.org +// GLFW 3.5 OSMesa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016 Google Inc. // Copyright (c) 2016-2017 Camilla Löwy diff --git a/src/platform.c b/src/platform.c index af1b0f44..9ca64963 100644 --- a/src/platform.c +++ b/src/platform.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2018 Camilla Löwy diff --git a/src/platform.h b/src/platform.h index 75652dcc..7ce4e015 100644 --- a/src/platform.h +++ b/src/platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2018 Camilla Löwy diff --git a/src/posix_module.c b/src/posix_module.c index 7d81c672..b3482d26 100644 --- a/src/posix_module.c +++ b/src/posix_module.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2021 Camilla Löwy // diff --git a/src/posix_poll.c b/src/posix_poll.c index b53e36e8..595cf717 100644 --- a/src/posix_poll.c +++ b/src/posix_poll.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2022 Camilla Löwy // diff --git a/src/posix_poll.h b/src/posix_poll.h index 4bdd2448..a0ef3962 100644 --- a/src/posix_poll.h +++ b/src/posix_poll.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2022 Camilla Löwy // diff --git a/src/posix_thread.c b/src/posix_thread.c index 3c355a53..bab74d4f 100644 --- a/src/posix_thread.c +++ b/src/posix_thread.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 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 5a5d7b7c..ce298a8b 100644 --- a/src/posix_thread.h +++ b/src/posix_thread.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 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 a1724084..4d7bd7ce 100644 --- a/src/posix_time.c +++ b/src/posix_time.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 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 94374adb..39faa0fc 100644 --- a/src/posix_time.h +++ b/src/posix_time.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 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 d9fabdea..274d21ca 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 8a23ffc4..209469e2 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 WGL - www.glfw.org +// GLFW 3.5 WGL - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/win32_init.c b/src/win32_init.c index 824e383c..77ab56ba 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 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 59389a90..6703485e 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 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 9ab6438b..2d8f59d0 100644 --- a/src/win32_joystick.h +++ b/src/win32_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2017 Camilla Löwy // diff --git a/src/win32_module.c b/src/win32_module.c index 47c8dff6..b76599b6 100644 --- a/src/win32_module.c +++ b/src/win32_module.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2021 Camilla Löwy // diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 87c85b94..1be43e66 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 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 7e3d8845..a2f86852 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 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 212e666c..6e418d7a 100644 --- a/src/win32_thread.c +++ b/src/win32_thread.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/win32_thread.h b/src/win32_thread.h index dd5948f0..ca96fae2 100644 --- a/src/win32_thread.h +++ b/src/win32_thread.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 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 a38e15dd..4a4b2cbb 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/win32_time.h b/src/win32_time.h index ef57a5a6..f72a5d04 100644 --- a/src/win32_time.h +++ b/src/win32_time.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 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 e6a9496c..7d26f0b1 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 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 1463d169..8b5d9f34 100644 --- a/src/window.c +++ b/src/window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - 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 3aff476d..025d46e5 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Wayland - www.glfw.org +// GLFW 3.5 Wayland - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/wl_monitor.c b/src/wl_monitor.c index df30313a..dca8ebbd 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Wayland - www.glfw.org +// GLFW 3.5 Wayland - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/wl_platform.h b/src/wl_platform.h index 149cd241..2a843b3c 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Wayland - www.glfw.org +// GLFW 3.5 Wayland - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/wl_window.c b/src/wl_window.c index 5b491ffb..218b4efd 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Wayland - www.glfw.org +// GLFW 3.5 Wayland - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/x11_init.c b/src/x11_init.c index e992f444..982c526c 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 X11 - www.glfw.org +// GLFW 3.5 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 38af7e0c..cab81127 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 X11 - www.glfw.org +// GLFW 3.5 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 14e363d1..30326c5b 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 X11 - www.glfw.org +// GLFW 3.5 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 e0295465..601387a9 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 X11 - www.glfw.org +// GLFW 3.5 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 6b8dfcac..68767cc3 100644 --- a/src/xkb_unicode.c +++ b/src/xkb_unicode.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 X11 - www.glfw.org +// GLFW 3.5 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 b07408f6..d52748ac 100644 --- a/src/xkb_unicode.h +++ b/src/xkb_unicode.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Linux - www.glfw.org +// GLFW 3.5 Linux - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // From dc557ecf38a42b0b93898a7aef69f6dc48bf0e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 29 Feb 2024 15:39:21 +0100 Subject: [PATCH 122/137] Fix minimum CMake version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 876eefa7..050ada3c 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ in the documentation for more information. ## Dependencies -GLFW itself needs only CMake 3.1 or later and the headers and libraries for your +GLFW itself needs only CMake 3.4 or later and the headers and libraries for your OS and window system. The examples and test programs depend on a number of tiny libraries. These are From bf945f1213728a98f7647380616f9cff9f6b3611 Mon Sep 17 00:00:00 2001 From: Grzesiek11 Date: Thu, 29 Feb 2024 15:50:50 +0000 Subject: [PATCH 123/137] Unlimited mouse button input mode This adds the GLFW_UNLIMITED_MOUSE_BUTTONS input mode which permits mouse buttons over GLFW_MOUSE_BUTTON_LAST to be reported to the mouse button callback. Closes #2423 --- README.md | 3 +++ docs/input.md | 25 ++++++++++++++++++++++--- docs/news.md | 11 +++++++++++ include/GLFW/glfw3.h | 38 ++++++++++++++++++++++++++------------ src/input.c | 22 ++++++++++++++++------ src/internal.h | 1 + tests/events.c | 1 + tests/window.c | 1 + 8 files changed, 81 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 050ada3c..d2615b17 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,9 @@ information on what to include when reporting a bug. ## Changelog since 3.4 + - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond + the limit of the mouse button tokens to be reported (#2423) + ## Contact diff --git a/docs/input.md b/docs/input.md index 56983b08..3ef1aebe 100644 --- a/docs/input.md +++ b/docs/input.md @@ -492,6 +492,20 @@ a mouse button callback. glfwSetMouseButtonCallback(window, mouse_button_callback); ``` +@anchor GLFW_UNLIMITED_MOUSE_BUTTONS +To handle all mouse buttons in the callback, instead of only ones with associated +[button tokens](@ref buttons), set the @ref GLFW_UNLIMITED_MOUSE_BUTTONS +input mode. + +```c +glfwSetInputMode(window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE); +``` + +When this input mode is enabled, GLFW doesn't limit the reported mouse buttons +to only those that have an associated button token, for compatibility with +earlier versions of GLFW, which never reported any buttons over +@ref GLFW_MOUSE_BUTTON_LAST, on which users could have relied on. + The callback function receives the [mouse button](@ref buttons), button action and [modifier bits](@ref mods). @@ -503,11 +517,16 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) } ``` +The mouse button is an integer that can be one of the +[mouse button tokens](@ref buttons) or, if the +@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode is set, any other positive value. + The action is one of `GLFW_PRESS` or `GLFW_RELEASE`. -The last reported state for every [supported mouse button](@ref buttons) is also +The last reported state for every [mouse button token](@ref buttons) is also saved in per-window state arrays that can be polled with @ref -glfwGetMouseButton. +glfwGetMouseButton. This is not effected by the @ref GLFW_UNLIMITED_MOUSE_BUTTONS +input mode. ```c int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT); @@ -540,7 +559,7 @@ had been processed in the meantime, the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`. The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any -[supported mouse button](@ref buttons). +[mouse button token](@ref buttons). ### Scroll input {#scrolling} diff --git a/docs/news.md b/docs/news.md index fd93a712..148d0871 100644 --- a/docs/news.md +++ b/docs/news.md @@ -5,6 +5,15 @@ ## New features {#features} +### Unlimited mouse buttons {#unlimited_mouse_buttons} + +GLFW now has an input mode which allows an unlimited number of mouse buttons to +be reported by the mouse buttton callback, rather than just the associated +[mouse button tokens](@ref buttons). This allows using mouse buttons with +values over 8. For compatibility with older versions, the +@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of +this. + ## Caveats {#caveats} ## Deprecations {#deprecations} @@ -19,6 +28,8 @@ ### New constants {#new_constants} +- @ref GLFW_UNLIMITED_MOUSE_BUTTONS + ## Release notes for earlier versions {#news_archive} - [Release notes for 3.4](https://www.glfw.org/docs/3.4/news.html) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 9a6ad6fd..bed739dc 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1149,11 +1149,12 @@ extern "C" { #define GLFW_OPENGL_CORE_PROFILE 0x00032001 #define GLFW_OPENGL_COMPAT_PROFILE 0x00032002 -#define GLFW_CURSOR 0x00033001 -#define GLFW_STICKY_KEYS 0x00033002 -#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 -#define GLFW_LOCK_KEY_MODS 0x00033004 -#define GLFW_RAW_MOUSE_MOTION 0x00033005 +#define GLFW_CURSOR 0x00033001 +#define GLFW_STICKY_KEYS 0x00033002 +#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 +#define GLFW_LOCK_KEY_MODS 0x00033004 +#define GLFW_RAW_MOUSE_MOTION 0x00033005 +#define GLFW_UNLIMITED_MOUSE_BUTTONS 0x00033006 #define GLFW_CURSOR_NORMAL 0x00034001 #define GLFW_CURSOR_HIDDEN 0x00034002 @@ -4676,8 +4677,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); * * This function sets an input mode option for the specified window. The mode * must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS, - * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or - * @ref GLFW_RAW_MOUSE_MOTION. + * @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS + * @ref GLFW_RAW_MOUSE_MOTION, or @ref GLFW_UNLIMITED_MOUSE_BUTTONS. * * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor * modes: @@ -4717,6 +4718,11 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); * attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE. Call @ref * glfwRawMouseMotionSupported to check for support. * + * If the mode is `GLFW_UNLIMITED_MOUSE_BUTTONS`, the value must be either + * `GLFW_TRUE` to disable the mouse button limit when calling the mouse button + * callback, or `GLFW_FALSE` to limit the mouse buttons sent to the callback + * to the mouse button token values up to `GLFW_MOUSE_BUTTON_LAST`. + * * @param[in] window The window whose input mode to set. * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`, * `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or @@ -4911,8 +4917,11 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key); * returns `GLFW_PRESS` the first time you call it for a mouse button that was * pressed, even if that mouse button has already been released. * + * The @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode does not effect the + * limit on buttons which can be polled with this function. + * * @param[in] window The desired window. - * @param[in] button The desired [mouse button](@ref buttons). + * @param[in] button The desired [mouse button token](@ref buttons). * @return One of `GLFW_PRESS` or `GLFW_RELEASE`. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref @@ -5288,10 +5297,15 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods * is called when a mouse button is pressed or released. * * When a window loses input focus, it will generate synthetic mouse button - * release events for all pressed mouse buttons. You can tell these events - * from user-generated events by the fact that the synthetic ones are generated - * after the focus loss event has been processed, i.e. after the - * [window focus callback](@ref glfwSetWindowFocusCallback) has been called. + * release events for all pressed mouse buttons with associated button tokens. + * You can tell these events from user-generated events by the fact that the + * synthetic ones are generated after the focus loss event has been processed, + * i.e. after the [window focus callback](@ref glfwSetWindowFocusCallback) has + * been called. + * + * The reported `button` value can be higher than `GLFW_MOUSE_BUTTON_LAST` if + * the button does not have an associated [button token](@ref buttons) and the + * @ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode is set. * * @param[in] window The window whose callback to set. * @param[in] callback The new callback, or `NULL` to remove the currently set diff --git a/src/input.c b/src/input.c index 3f8ddb30..8148a57d 100644 --- a/src/input.c +++ b/src/input.c @@ -348,20 +348,22 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods) { assert(window != NULL); assert(button >= 0); - assert(button <= GLFW_MOUSE_BUTTON_LAST); assert(action == GLFW_PRESS || action == GLFW_RELEASE); assert(mods == (mods & GLFW_MOD_MASK)); - if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST) + if (button < 0 || (!window->disableMouseButtonLimit && button > GLFW_MOUSE_BUTTON_LAST)) return; if (!window->lockKeyMods) mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK); - if (action == GLFW_RELEASE && window->stickyMouseButtons) - window->mouseButtons[button] = _GLFW_STICK; - else - window->mouseButtons[button] = (char) action; + if (button <= GLFW_MOUSE_BUTTON_LAST) + { + if (action == GLFW_RELEASE && window->stickyMouseButtons) + window->mouseButtons[button] = _GLFW_STICK; + else + window->mouseButtons[button] = (char) action; + } if (window->callbacks.mouseButton) window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods); @@ -576,6 +578,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode) return window->lockKeyMods; case GLFW_RAW_MOUSE_MOTION: return window->rawMouseMotion; + case GLFW_UNLIMITED_MOUSE_BUTTONS: + return window->disableMouseButtonLimit; } _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); @@ -683,6 +687,12 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) _glfw.platform.setRawMouseMotion(window, value); return; } + + case GLFW_UNLIMITED_MOUSE_BUTTONS: + { + window->disableMouseButtonLimit = value ? GLFW_TRUE : GLFW_FALSE; + return; + } } _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); diff --git a/src/internal.h b/src/internal.h index 76f3ede2..eae87c73 100644 --- a/src/internal.h +++ b/src/internal.h @@ -544,6 +544,7 @@ struct _GLFWwindow GLFWbool stickyKeys; GLFWbool stickyMouseButtons; GLFWbool lockKeyMods; + GLFWbool disableMouseButtonLimit; int cursorMode; char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1]; char keys[GLFW_KEY_LAST + 1]; diff --git a/tests/events.c b/tests/events.c index fdc3c199..ab3b99a7 100644 --- a/tests/events.c +++ b/tests/events.c @@ -630,6 +630,7 @@ int main(int argc, char** argv) glfwTerminate(); exit(EXIT_FAILURE); } + glfwSetInputMode(slots[i].window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE); glfwSetWindowUserPointer(slots[i].window, slots + i); diff --git a/tests/window.c b/tests/window.c index c81bf024..ffea5dbf 100644 --- a/tests/window.c +++ b/tests/window.c @@ -78,6 +78,7 @@ int main(int argc, char** argv) glfwTerminate(); exit(EXIT_FAILURE); } + glfwSetInputMode(window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE); glfwMakeContextCurrent(window); gladLoadGL(glfwGetProcAddress); From 42dc1ffaee922629cf503dac5888b95a2f7532ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 8 Mar 2024 15:22:36 +0100 Subject: [PATCH 124/137] Wayland: Fix leak of surface scaling objects --- README.md | 1 + src/wl_window.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index d2615b17..77a98ca7 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ information on what to include when reporting a bug. - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond the limit of the mouse button tokens to be reported (#2423) + - [Wayland] Bugfix: The fractional scaling related objects were not destroyed ## Contact diff --git a/src/wl_window.c b/src/wl_window.c index 218b4efd..9a411155 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2183,6 +2183,12 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) if (window == _glfw.wl.keyboardFocus) _glfw.wl.keyboardFocus = NULL; + if (window->wl.fractionalScale) + wp_fractional_scale_v1_destroy(window->wl.fractionalScale); + + if (window->wl.scalingViewport) + wp_viewport_destroy(window->wl.scalingViewport); + if (window->wl.activationToken) xdg_activation_token_v1_destroy(window->wl.activationToken); From 860c8ef38f0200824a8f038a5e6502963ec9c443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 11 Mar 2024 11:33:51 +0100 Subject: [PATCH 125/137] Null: Add Vulkan 'window' surface creation This adds support for Vulkan 'window' surface creation on the Null platform via the VK_EXT_headless_surface extension, where available. Tested with MoltenVK. --- README.md | 1 + src/internal.h | 2 ++ src/null_platform.h | 11 +++++++++++ src/null_window.c | 33 ++++++++++++++++++++++++++++++--- src/vulkan.c | 2 ++ 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 77a98ca7..e514ced3 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ information on what to include when reporting a bug. - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond the limit of the mouse button tokens to be reported (#2423) - [Wayland] Bugfix: The fractional scaling related objects were not destroyed + - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` ## Contact diff --git a/src/internal.h b/src/internal.h index eae87c73..e36c4455 100644 --- a/src/internal.h +++ b/src/internal.h @@ -277,6 +277,7 @@ typedef enum VkStructureType 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_HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000, VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF } VkStructureType; @@ -861,6 +862,7 @@ struct _GLFWlibrary GLFWbool KHR_xlib_surface; GLFWbool KHR_xcb_surface; GLFWbool KHR_wayland_surface; + GLFWbool EXT_headless_surface; } vk; struct { diff --git a/src/null_platform.h b/src/null_platform.h index 8222b0de..dbcb835b 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -156,6 +156,17 @@ #define GLFW_NULL_SC_MENU 120 #define GLFW_NULL_SC_LAST GLFW_NULL_SC_MENU +typedef VkFlags VkHeadlessSurfaceCreateFlagsEXT; + +typedef struct VkHeadlessSurfaceCreateInfoEXT +{ + VkStructureType sType; + const void* pNext; + VkHeadlessSurfaceCreateFlagsEXT flags; +} VkHeadlessSurfaceCreateInfoEXT; + +typedef VkResult (APIENTRY *PFN_vkCreateHeadlessSurfaceEXT)(VkInstance,const VkHeadlessSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*); + // Null-specific per-window data // typedef struct _GLFWwindowNull diff --git a/src/null_window.c b/src/null_window.c index 75326065..f31489b0 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -28,6 +28,7 @@ #include "internal.h" #include +#include static void applySizeLimits(_GLFWwindow* window, int* width, int* height) { @@ -699,13 +700,18 @@ int _glfwGetKeyScancodeNull(int key) void _glfwGetRequiredInstanceExtensionsNull(char** extensions) { + if (!_glfw.vk.KHR_surface || !_glfw.vk.EXT_headless_surface) + return; + + extensions[0] = "VK_KHR_surface"; + extensions[1] = "VK_EXT_headless_surface"; } GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily) { - return GLFW_FALSE; + return GLFW_TRUE; } VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, @@ -713,7 +719,28 @@ VkResult _glfwCreateWindowSurfaceNull(VkInstance instance, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface) { - // This seems like the most appropriate error to return here - return VK_ERROR_EXTENSION_NOT_PRESENT; + PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT = + (PFN_vkCreateHeadlessSurfaceEXT) + vkGetInstanceProcAddr(instance, "vkCreateHeadlessSurfaceEXT"); + if (!vkCreateHeadlessSurfaceEXT) + { + _glfwInputError(GLFW_API_UNAVAILABLE, + "Null: Vulkan instance missing VK_EXT_headless_surface extension"); + return VK_ERROR_EXTENSION_NOT_PRESENT; + } + + VkHeadlessSurfaceCreateInfoEXT sci; + memset(&sci, 0, sizeof(sci)); + sci.sType = VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT; + + const VkResult err = vkCreateHeadlessSurfaceEXT(instance, &sci, allocator, surface); + if (err) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Null: Failed to create Vulkan surface: %s", + _glfwGetVulkanResultString(err)); + } + + return err; } diff --git a/src/vulkan.c b/src/vulkan.c index 274d21ca..3f76c540 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -142,6 +142,8 @@ GLFWbool _glfwInitVulkan(int mode) _glfw.vk.KHR_xcb_surface = GLFW_TRUE; else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0) _glfw.vk.KHR_wayland_surface = GLFW_TRUE; + else if (strcmp(ep[i].extensionName, "VK_EXT_headless_surface") == 0) + _glfw.vk.EXT_headless_surface = GLFW_TRUE; } _glfw_free(ep); From 738dd6ff1d4f79cf4f8b8af0621a8afb40c51b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 11 Mar 2024 14:29:07 +0100 Subject: [PATCH 126/137] Null: Add limited EGL context creation on Mesa This provides very limited support for context creation via EGL on the Null platform. It supports Unix-like systems with a version of Mesa that provides EGL_MESA_platform_surfaceless. Even then, the actual framebuffer provided is not resized along with the 'window'. That will hopefully change once context and framebuffer creation are separated, but this commit should at least allow more applications than before to run on the Null platform. --- README.md | 1 + src/egl_context.c | 41 +++++++++++++++++++++++++++++++++-------- src/internal.h | 8 ++++++++ src/null_window.c | 7 +++++-- 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e514ced3..825329ca 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,7 @@ information on what to include when reporting a bug. the limit of the mouse button tokens to be reported (#2423) - [Wayland] Bugfix: The fractional scaling related objects were not destroyed - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` + - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` ## Contact diff --git a/src/egl_context.c b/src/egl_context.c index 06deb76f..8dbe3caa 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -92,7 +92,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, EGLConfig* nativeConfigs; _GLFWfbconfig* usableConfigs; const _GLFWfbconfig* closest; - int i, nativeCount, usableCount, apiBit; + int i, nativeCount, usableCount, apiBit, surfaceTypeBit; GLFWbool wrongApiAvailable = GLFW_FALSE; if (ctxconfig->client == GLFW_OPENGL_ES_API) @@ -105,6 +105,11 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, else apiBit = EGL_OPENGL_BIT; + if (_glfw.egl.platform == EGL_PLATFORM_SURFACELESS_MESA) + surfaceTypeBit = EGL_PBUFFER_BIT; + else + surfaceTypeBit = EGL_WINDOW_BIT; + if (fbconfig->stereo) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Stereo rendering not supported"); @@ -133,8 +138,7 @@ static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER) continue; - // Only consider window EGLConfigs - if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT)) + if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & surfaceTypeBit)) continue; #if defined(_GLFW_X11) @@ -420,6 +424,8 @@ GLFWbool _glfwInitEGL(void) _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglDestroyContext"); _glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface) _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreateWindowSurface"); + _glfw.egl.CreatePbufferSurface = (PFN_eglCreatePbufferSurface) + _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglCreatePbufferSurface"); _glfw.egl.MakeCurrent = (PFN_eglMakeCurrent) _glfwPlatformGetModuleSymbol(_glfw.egl.handle, "eglMakeCurrent"); _glfw.egl.SwapBuffers = (PFN_eglSwapBuffers) @@ -442,6 +448,7 @@ GLFWbool _glfwInitEGL(void) !_glfw.egl.DestroySurface || !_glfw.egl.DestroyContext || !_glfw.egl.CreateWindowSurface || + !_glfw.egl.CreatePbufferSurface || !_glfw.egl.MakeCurrent || !_glfw.egl.SwapBuffers || !_glfw.egl.SwapInterval || @@ -477,6 +484,8 @@ GLFWbool _glfwInitEGL(void) _glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions); _glfw.egl.ANGLE_platform_angle_metal = _glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions); + _glfw.egl.MESA_platform_surfaceless = + _glfwStringInExtensionString("EGL_MESA_platform_surfaceless", extensions); } if (_glfw.egl.EXT_platform_base) @@ -708,20 +717,36 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, SET_ATTRIB(EGL_PRESENT_OPAQUE_EXT, !fbconfig->transparent); } + if (_glfw.egl.platform == EGL_PLATFORM_SURFACELESS_MESA) + { + int width, height; + _glfw.platform.getFramebufferSize(window, &width, &height); + + SET_ATTRIB(EGL_WIDTH, width); + SET_ATTRIB(EGL_HEIGHT, height); + } + SET_ATTRIB(EGL_NONE, EGL_NONE); native = _glfw.platform.getEGLNativeWindow(window); - // HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT - // despite reporting EGL_EXT_platform_base - if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE) + if (!_glfw.egl.platform || _glfw.egl.platform == EGL_PLATFORM_ANGLE_ANGLE) { + // HACK: Also use non-platform function for ANGLE, as it does not + // implement eglCreatePlatformWindowSurfaceEXT despite reporting + // support for EGL_EXT_platform_base window->context.egl.surface = - eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs); + eglCreateWindowSurface(_glfw.egl.display, config, native, attribs); + } + else if (_glfw.egl.platform == EGL_PLATFORM_SURFACELESS_MESA) + { + // HACK: Use a pbuffer surface as the default framebuffer + window->context.egl.surface = + eglCreatePbufferSurface(_glfw.egl.display, config, attribs); } else { window->context.egl.surface = - eglCreateWindowSurface(_glfw.egl.display, config, native, attribs); + eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs); } if (window->context.egl.surface == EGL_NO_SURFACE) diff --git a/src/internal.h b/src/internal.h index e36c4455..ad59efb5 100644 --- a/src/internal.h +++ b/src/internal.h @@ -150,6 +150,9 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); #define EGL_NO_DISPLAY ((EGLDisplay) 0) #define EGL_NO_CONTEXT ((EGLContext) 0) #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0) +#define EGL_PBUFFER_BIT 0x0001 +#define EGL_WIDTH 0x3057 +#define EGL_HEIGHT 0x3056 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 @@ -181,6 +184,7 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); #define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450 #define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489 #define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f +#define EGL_PLATFORM_SURFACELESS_MESA 0x31dd typedef int EGLint; typedef unsigned int EGLBoolean; @@ -205,6 +209,7 @@ typedef EGLContext (APIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLCon typedef EGLBoolean (APIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); typedef EGLBoolean (APIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); typedef EGLSurface (APIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); +typedef EGLSurface (APIENTRY * PFN_eglCreatePbufferSurface)(EGLDisplay,EGLContext,const EGLint*); typedef EGLBoolean (APIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); typedef EGLBoolean (APIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); typedef EGLBoolean (APIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); @@ -221,6 +226,7 @@ typedef GLFWglproc (APIENTRY * PFN_eglGetProcAddress)(const char*); #define eglDestroySurface _glfw.egl.DestroySurface #define eglDestroyContext _glfw.egl.DestroyContext #define eglCreateWindowSurface _glfw.egl.CreateWindowSurface +#define eglCreatePbufferSurface _glfw.egl.CreatePbufferSurface #define eglMakeCurrent _glfw.egl.MakeCurrent #define eglSwapBuffers _glfw.egl.SwapBuffers #define eglSwapInterval _glfw.egl.SwapInterval @@ -813,6 +819,7 @@ struct _GLFWlibrary GLFWbool ANGLE_platform_angle_d3d; GLFWbool ANGLE_platform_angle_vulkan; GLFWbool ANGLE_platform_angle_metal; + GLFWbool MESA_platform_surfaceless; void* handle; @@ -827,6 +834,7 @@ struct _GLFWlibrary PFN_eglDestroySurface DestroySurface; PFN_eglDestroyContext DestroyContext; PFN_eglCreateWindowSurface CreateWindowSurface; + PFN_eglCreatePbufferSurface CreatePbufferSurface; PFN_eglMakeCurrent MakeCurrent; PFN_eglSwapBuffers SwapBuffers; PFN_eglSwapInterval SwapInterval; diff --git a/src/null_window.c b/src/null_window.c index f31489b0..f0e1dcc9 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -553,12 +553,15 @@ const char* _glfwGetClipboardStringNull(void) EGLenum _glfwGetEGLPlatformNull(EGLint** attribs) { - return 0; + if (_glfw.egl.EXT_platform_base && _glfw.egl.MESA_platform_surfaceless) + return EGL_PLATFORM_SURFACELESS_MESA; + else + return 0; } EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void) { - return 0; + return EGL_DEFAULT_DISPLAY; } EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window) From 38ec7abd3baffdd3ec4e6f8cbb5384cda8882ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 10 Mar 2024 16:18:08 +0100 Subject: [PATCH 127/137] Fix missing assertions for native access functions --- src/cocoa_monitor.m | 3 +++ src/cocoa_window.m | 5 +++++ src/egl_context.c | 4 ++++ src/glx_context.c | 4 ++++ src/nsgl_context.m | 3 +++ src/osmesa_context.c | 2 ++ src/wgl_context.c | 2 ++ src/win32_monitor.c | 5 +++++ src/win32_window.c | 3 +++ src/wl_monitor.c | 3 +++ src/wl_window.c | 2 ++ src/x11_monitor.c | 5 +++++ src/x11_window.c | 4 ++++ 13 files changed, 45 insertions(+) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 75f8ec53..150a7477 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -628,6 +629,8 @@ void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 5fa360dd..32df0b9e 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -30,6 +30,7 @@ #include #include +#include // HACK: This enum value is missing from framework headers on OS X 10.11 despite // having been (according to documentation) added in Mac OS X 10.7 @@ -2041,6 +2042,8 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) @@ -2056,6 +2059,8 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) GLFWAPI id glfwGetCocoaView(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) diff --git a/src/egl_context.c b/src/egl_context.c index 8dbe3caa..831a9cf7 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -909,6 +909,8 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void) GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT); if (window->context.source != GLFW_EGL_CONTEXT_API) @@ -923,6 +925,8 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE); if (window->context.source != GLFW_EGL_CONTEXT_API) diff --git a/src/glx_context.c b/src/glx_context.c index fae55966..a971585f 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -678,6 +678,8 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -698,6 +700,8 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) diff --git a/src/nsgl_context.m b/src/nsgl_context.m index d34cc224..e93eb4d4 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -30,6 +30,7 @@ #include #include +#include static void makeContextCurrentNSGL(_GLFWwindow* window) { @@ -362,6 +363,8 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 0b9d83a2..88f5adb8 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -370,6 +370,8 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle, GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (window->context.source != GLFW_OSMESA_CONTEXT_API) diff --git a/src/wgl_context.c b/src/wgl_context.c index 209469e2..dd92b6f4 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -776,6 +776,8 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 1be43e66..d13a9040 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -33,6 +33,7 @@ #include #include #include +#include // Callback for EnumDisplayMonitors in createMonitor @@ -540,6 +541,8 @@ void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) @@ -554,6 +557,8 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle) GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) diff --git a/src/win32_window.c b/src/win32_window.c index 7d26f0b1..5cd08f68 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -2577,6 +2578,8 @@ VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) diff --git a/src/wl_monitor.c b/src/wl_monitor.c index dca8ebbd..9f56c3ae 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "wayland-client-protocol.h" @@ -259,6 +260,8 @@ void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) diff --git a/src/wl_window.c b/src/wl_window.c index 9a411155..812b9e91 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -3298,6 +3298,8 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void) GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index cab81127..8f8e2bcd 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -33,6 +33,7 @@ #include #include #include +#include // Check whether the display mode should be included in enumeration @@ -612,6 +613,8 @@ void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -626,6 +629,8 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle) GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) diff --git a/src/x11_window.c b/src/x11_window.c index 601387a9..fa2d390f 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -3303,6 +3303,8 @@ GLFWAPI Display* glfwGetX11Display(void) GLFWAPI Window glfwGetX11Window(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -3316,6 +3318,8 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* handle) GLFWAPI void glfwSetX11SelectionString(const char* string) { + assert(string != NULL); + _GLFW_REQUIRE_INIT(); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) From 68dcea0d7fcd91011695dbc74d6b1c999fcda2bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 18 Jan 2024 21:33:27 +0100 Subject: [PATCH 128/137] Place assertions for handles after init check This lets automated testing check that GLFW_NOT_INITIALIZED is emitted for every public function. --- src/cocoa_monitor.m | 6 +- src/cocoa_window.m | 12 ++-- src/context.c | 8 +-- src/egl_context.c | 8 +-- src/glx_context.c | 12 ++-- src/input.c | 58 +++++++++------- src/monitor.c | 55 ++++++++------- src/nsgl_context.m | 6 +- src/osmesa_context.c | 14 ++-- src/vulkan.c | 11 +-- src/wgl_context.c | 6 +- src/win32_monitor.c | 12 ++-- src/win32_window.c | 6 +- src/window.c | 162 +++++++++++++++++++++++++------------------ src/wl_monitor.c | 6 +- src/wl_window.c | 6 +- src/x11_monitor.c | 12 ++-- src/x11_window.c | 6 +- 18 files changed, 226 insertions(+), 180 deletions(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 150a7477..1abf6ff5 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -628,9 +628,6 @@ void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) @@ -639,6 +636,9 @@ GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) return kCGNullDirectDisplay; } + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + return monitor->ns.displayID; } diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 32df0b9e..780bc7d3 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -2041,9 +2041,6 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) @@ -2053,14 +2050,14 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) return nil; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + return window->ns.object; } GLFWAPI id glfwGetCocoaView(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) @@ -2070,6 +2067,9 @@ GLFWAPI id glfwGetCocoaView(GLFWwindow* handle) return nil; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + return window->ns.view; } diff --git a/src/context.c b/src/context.c index 7232dc2a..f4fa63ad 100644 --- a/src/context.c +++ b/src/context.c @@ -615,11 +615,11 @@ GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* previous; - _GLFW_REQUIRE_INIT(); - previous = _glfwPlatformGetTls(&_glfw.contextSlot); if (window && window->context.client == GLFW_NO_API) @@ -647,11 +647,11 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void) GLFWAPI void glfwSwapBuffers(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - if (window->context.client == GLFW_NO_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, diff --git a/src/egl_context.c b/src/egl_context.c index 831a9cf7..b901c1be 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -908,11 +908,11 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void) GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT); - if (window->context.source != GLFW_EGL_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); @@ -924,11 +924,11 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE); - if (window->context.source != GLFW_EGL_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); diff --git a/src/glx_context.c b/src/glx_context.c index a971585f..a2464a9d 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -677,9 +677,6 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -688,6 +685,9 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) return NULL; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); @@ -699,9 +699,6 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -710,6 +707,9 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) return None; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); diff --git a/src/input.c b/src/input.c index 8148a57d..c619eefc 100644 --- a/src/input.c +++ b/src/input.c @@ -561,11 +561,11 @@ void _glfwCenterCursorInContentArea(_GLFWwindow* window) GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode) { + _GLFW_REQUIRE_INIT_OR_RETURN(0); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(0); - switch (mode) { case GLFW_CURSOR: @@ -588,11 +588,11 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode) GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - switch (mode) { case GLFW_CURSOR: @@ -744,11 +744,11 @@ GLFWAPI int glfwGetKeyScancode(int key) GLFWAPI int glfwGetKey(GLFWwindow* handle, int key) { + _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE); - if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST) { _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key); @@ -767,11 +767,11 @@ GLFWAPI int glfwGetKey(GLFWwindow* handle, int key) GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button) { + _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE); - if (button < GLFW_MOUSE_BUTTON_1 || button > GLFW_MOUSE_BUTTON_LAST) { _glfwInputError(GLFW_INVALID_ENUM, "Invalid mouse button %i", button); @@ -790,9 +790,6 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button) GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - if (xpos) *xpos = 0; if (ypos) @@ -800,6 +797,9 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos) _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (window->cursorMode == GLFW_CURSOR_DISABLED) { if (xpos) @@ -813,11 +813,11 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos) GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX || ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX) { @@ -907,10 +907,10 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape) GLFWAPI void glfwDestroyCursor(GLFWcursor* handle) { - _GLFWcursor* cursor = (_GLFWcursor*) handle; - _GLFW_REQUIRE_INIT(); + _GLFWcursor* cursor = (_GLFWcursor*) handle; + if (cursor == NULL) return; @@ -942,12 +942,12 @@ GLFWAPI void glfwDestroyCursor(GLFWcursor* handle) GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) windowHandle; _GLFWcursor* cursor = (_GLFWcursor*) cursorHandle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - window->cursor = cursor; _glfw.platform.setCursor(window, cursor); @@ -955,30 +955,33 @@ GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle) GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWkeyfun, window->callbacks.key, cbfun); return cbfun; } GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWcharfun, window->callbacks.character, cbfun); return cbfun; } GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWcharmodsfun, window->callbacks.charmods, cbfun); return cbfun; } @@ -986,10 +989,11 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmods GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle, GLFWmousebuttonfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWmousebuttonfun, window->callbacks.mouseButton, cbfun); return cbfun; } @@ -997,10 +1001,11 @@ GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle, GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle, GLFWcursorposfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWcursorposfun, window->callbacks.cursorPos, cbfun); return cbfun; } @@ -1008,10 +1013,11 @@ GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle, GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle, GLFWcursorenterfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWcursorenterfun, window->callbacks.cursorEnter, cbfun); return cbfun; } @@ -1019,20 +1025,22 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle, GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle, GLFWscrollfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWscrollfun, window->callbacks.scroll, cbfun); return cbfun; } GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWdropfun, window->callbacks.drop, cbfun); return cbfun; } diff --git a/src/monitor.c b/src/monitor.c index 6f802e32..cc95efb6 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -325,9 +325,6 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void) GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - if (xpos) *xpos = 0; if (ypos) @@ -335,6 +332,9 @@ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos) _GLFW_REQUIRE_INIT(); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _glfw.platform.getMonitorPos(monitor, xpos, ypos); } @@ -342,9 +342,6 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle, int* xpos, int* ypos, int* width, int* height) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - if (xpos) *xpos = 0; if (ypos) @@ -356,14 +353,14 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle, _GLFW_REQUIRE_INIT(); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _glfw.platform.getMonitorWorkarea(monitor, xpos, ypos, width, height); } GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - if (widthMM) *widthMM = 0; if (heightMM) @@ -371,6 +368,9 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* _GLFW_REQUIRE_INIT(); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + if (widthMM) *widthMM = monitor->widthMM; if (heightMM) @@ -380,42 +380,46 @@ GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle, float* xscale, float* yscale) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - if (xscale) *xscale = 0.f; if (yscale) *yscale = 0.f; _GLFW_REQUIRE_INIT(); + + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + _glfw.platform.getMonitorContentScale(monitor, xscale, yscale); } GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return monitor->name; } GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer) { + _GLFW_REQUIRE_INIT(); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; assert(monitor != NULL); - _GLFW_REQUIRE_INIT(); monitor->userPointer = pointer; } GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return monitor->userPointer; } @@ -428,14 +432,15 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun) GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); assert(count != NULL); *count = 0; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + if (!refreshVideoModes(monitor)) return NULL; @@ -445,11 +450,11 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count) GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - if (!_glfw.platform.getVideoMode(monitor, &monitor->currentMode)) return NULL; @@ -462,12 +467,13 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) unsigned short* values; GLFWgammaramp ramp; const GLFWgammaramp* original; - assert(handle != NULL); assert(gamma > 0.f); assert(gamma <= FLT_MAX); _GLFW_REQUIRE_INIT(); + assert(handle != NULL); + if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma); @@ -505,11 +511,11 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _glfwFreeGammaArrays(&monitor->currentRamp); if (!_glfw.platform.getGammaRamp(monitor, &monitor->currentRamp)) return NULL; @@ -519,8 +525,6 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle) GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); assert(ramp != NULL); assert(ramp->size > 0); assert(ramp->red != NULL); @@ -529,6 +533,9 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp) _GLFW_REQUIRE_INIT(); + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + if (ramp->size <= 0) { _glfwInputError(GLFW_INVALID_VALUE, diff --git a/src/nsgl_context.m b/src/nsgl_context.m index e93eb4d4..57f117ba 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -362,9 +362,6 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) @@ -374,6 +371,9 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) return nil; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 88f5adb8..0bb375a8 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -296,11 +296,12 @@ GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width, { void* mesaBuffer; GLint mesaWidth, mesaHeight, mesaFormat; - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (window->context.source != GLFW_OSMESA_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); @@ -335,11 +336,12 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle, { void* mesaBuffer; GLint mesaWidth, mesaHeight, mesaBytes; - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (window->context.source != GLFW_OSMESA_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); @@ -369,11 +371,11 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle, GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - if (window->context.source != GLFW_OSMESA_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); diff --git a/src/vulkan.c b/src/vulkan.c index 3f76c540..9c87fcfe 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -274,11 +274,11 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily) { + _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); + assert(instance != VK_NULL_HANDLE); assert(device != VK_NULL_HANDLE); - _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); - if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER)) return GLFW_FALSE; @@ -299,15 +299,16 @@ GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(instance != VK_NULL_HANDLE); - assert(window != NULL); assert(surface != NULL); *surface = VK_NULL_HANDLE; _GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + assert(instance != VK_NULL_HANDLE); + if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER)) return VK_ERROR_INITIALIZATION_FAILED; diff --git a/src/wgl_context.c b/src/wgl_context.c index dd92b6f4..1c9189fa 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -775,9 +775,6 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) @@ -787,6 +784,9 @@ GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) return NULL; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); diff --git a/src/win32_monitor.c b/src/win32_monitor.c index d13a9040..87e5c206 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -540,9 +540,6 @@ void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) @@ -551,14 +548,14 @@ GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle) return NULL; } + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + return monitor->win32.publicAdapterName; } GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) @@ -567,6 +564,9 @@ GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle) return NULL; } + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + return monitor->win32.publicDisplayName; } diff --git a/src/win32_window.c b/src/win32_window.c index 5cd08f68..d014944b 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2577,9 +2577,6 @@ VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) @@ -2589,6 +2586,9 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle) return NULL; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + return window->win32.handle; } diff --git a/src/window.c b/src/window.c index 8b5d9f34..e03121a4 100644 --- a/src/window.c +++ b/src/window.c @@ -467,10 +467,10 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value) GLFWAPI void glfwDestroyWindow(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; + // Allow closing of NULL (to match the behavior of free) if (window == NULL) return; @@ -501,40 +501,43 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow* handle) GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(0); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(0); return window->shouldClose; } GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); window->shouldClose = value; } GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - return window->title; } GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); assert(title != NULL); _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + char* prev = window->title; window->title = _glfw_strdup(title); @@ -546,14 +549,15 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle, int count, const GLFWimage* images) { int i; - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); assert(count >= 0); assert(count == 0 || images != NULL); _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (count < 0) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid image count for window icon"); @@ -577,25 +581,26 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle, GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - if (xpos) *xpos = 0; if (ypos) *ypos = 0; _GLFW_REQUIRE_INIT(); + + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _glfw.platform.getWindowPos(window, xpos, ypos); } GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - if (window->monitor) return; @@ -604,27 +609,29 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos) GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - if (width) *width = 0; if (height) *height = 0; _GLFW_REQUIRE_INIT(); + + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _glfw.platform.getWindowSize(window, width, height); } GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); assert(width >= 0); assert(height >= 0); _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + window->videoMode.width = width; window->videoMode.height = height; @@ -635,11 +642,11 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle, int minwidth, int minheight, int maxwidth, int maxheight) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - if (minwidth != GLFW_DONT_CARE && minheight != GLFW_DONT_CARE) { if (minwidth < 0 || minheight < 0) @@ -678,13 +685,14 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle, GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); assert(numer != 0); assert(denom != 0); _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE) { if (numer <= 0 || denom <= 0) @@ -707,15 +715,16 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom) GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - if (width) *width = 0; if (height) *height = 0; _GLFW_REQUIRE_INIT(); + + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _glfw.platform.getFramebufferSize(window, width, height); } @@ -723,9 +732,6 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle, int* left, int* top, int* right, int* bottom) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - if (left) *left = 0; if (top) @@ -736,43 +742,50 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle, *bottom = 0; _GLFW_REQUIRE_INIT(); + + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _glfw.platform.getWindowFrameSize(window, left, top, right, bottom); } GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle, float* xscale, float* yscale) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - if (xscale) *xscale = 0.f; if (yscale) *yscale = 0.f; _GLFW_REQUIRE_INIT(); + + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + _glfw.platform.getWindowContentScale(window, xscale, yscale); } GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(0.f); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(0.f); return _glfw.platform.getWindowOpacity(window); } GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); assert(opacity == opacity); assert(opacity >= 0.f); assert(opacity <= 1.f); _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (opacity != opacity || opacity < 0.f || opacity > 1.f) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid window opacity %f", opacity); @@ -784,29 +797,31 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity) GLFWAPI void glfwIconifyWindow(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); _glfw.platform.iconifyWindow(window); } GLFWAPI void glfwRestoreWindow(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); _glfw.platform.restoreWindow(window); } GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - if (window->monitor) return; @@ -815,11 +830,11 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle) GLFWAPI void glfwShowWindow(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - if (window->monitor) return; @@ -831,21 +846,21 @@ GLFWAPI void glfwShowWindow(GLFWwindow* handle) GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - _glfw.platform.requestWindowAttention(window); } GLFWAPI void glfwHideWindow(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - if (window->monitor) return; @@ -854,21 +869,21 @@ GLFWAPI void glfwHideWindow(GLFWwindow* handle) GLFWAPI void glfwFocusWindow(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - _glfw.platform.focusWindow(window); } GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) { + _GLFW_REQUIRE_INIT_OR_RETURN(0); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(0); - switch (attrib) { case GLFW_FOCUSED: @@ -927,11 +942,11 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); - value = value ? GLFW_TRUE : GLFW_FALSE; switch (attrib) @@ -973,10 +988,11 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return (GLFWmonitor*) window->monitor; } @@ -986,14 +1002,15 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh, int width, int height, int refreshRate) { - _GLFWwindow* window = (_GLFWwindow*) wh; - _GLFWmonitor* monitor = (_GLFWmonitor*) mh; - assert(window != NULL); assert(width >= 0); assert(height >= 0); _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) wh; + _GLFWmonitor* monitor = (_GLFWmonitor*) mh; + assert(window != NULL); + if (width <= 0 || height <= 0) { _glfwInputError(GLFW_INVALID_VALUE, @@ -1021,29 +1038,32 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh, GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer) { + _GLFW_REQUIRE_INIT(); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT(); window->userPointer = pointer; } GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); return window->userPointer; } GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle, GLFWwindowposfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWwindowposfun, window->callbacks.pos, cbfun); return cbfun; } @@ -1051,10 +1071,11 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle, GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle, GLFWwindowsizefun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWwindowsizefun, window->callbacks.size, cbfun); return cbfun; } @@ -1062,10 +1083,11 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle, GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle, GLFWwindowclosefun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWwindowclosefun, window->callbacks.close, cbfun); return cbfun; } @@ -1073,10 +1095,11 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle, GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle, GLFWwindowrefreshfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWwindowrefreshfun, window->callbacks.refresh, cbfun); return cbfun; } @@ -1084,10 +1107,11 @@ GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle, GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle, GLFWwindowfocusfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWwindowfocusfun, window->callbacks.focus, cbfun); return cbfun; } @@ -1095,10 +1119,11 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle, GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle, GLFWwindowiconifyfun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWwindowiconifyfun, window->callbacks.iconify, cbfun); return cbfun; } @@ -1106,10 +1131,11 @@ GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle, GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle, GLFWwindowmaximizefun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWwindowmaximizefun, window->callbacks.maximize, cbfun); return cbfun; } @@ -1117,10 +1143,11 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle, GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle, GLFWframebuffersizefun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWframebuffersizefun, window->callbacks.fbsize, cbfun); return cbfun; } @@ -1128,10 +1155,11 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* handle, GLFWwindowcontentscalefun cbfun) { + _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); _GLFW_SWAP(GLFWwindowcontentscalefun, window->callbacks.scale, cbfun); return cbfun; } diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 9f56c3ae..1ec5f5af 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -259,9 +259,6 @@ void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) @@ -270,6 +267,9 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) return NULL; } + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + return monitor->wl.output; } diff --git a/src/wl_window.c b/src/wl_window.c index 812b9e91..dc7dcd07 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -3297,9 +3297,6 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void) GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) @@ -3309,6 +3306,9 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle) return NULL; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + return window->wl.surface; } diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 8f8e2bcd..3af82752 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -612,9 +612,6 @@ void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -623,14 +620,14 @@ GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle) return None; } + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + return monitor->x11.crtc; } GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; - assert(monitor != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -639,6 +636,9 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle) return None; } + _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + assert(monitor != NULL); + return monitor->x11.output; } diff --git a/src/x11_window.c b/src/x11_window.c index fa2d390f..322349f0 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -3302,9 +3302,6 @@ GLFWAPI Display* glfwGetX11Display(void) GLFWAPI Window glfwGetX11Window(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -3313,6 +3310,9 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* handle) return None; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + return window->x11.handle; } From 072f660d93144aa3de3ee8964f3165dff0e3866d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 29 Feb 2024 16:51:41 +0100 Subject: [PATCH 129/137] Allow C99 booleans --- src/internal.h | 2 ++ src/wl_platform.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internal.h b/src/internal.h index ad59efb5..4f097aa8 100644 --- a/src/internal.h +++ b/src/internal.h @@ -48,6 +48,8 @@ #define GLFW_INCLUDE_NONE #include "../include/GLFW/glfw3.h" +#include + #define _GLFW_INSERT_FIRST 0 #define _GLFW_INSERT_LAST 1 diff --git a/src/wl_platform.h b/src/wl_platform.h index 2a843b3c..f3e8cba2 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -28,8 +28,6 @@ #include #include -#include - typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; typedef struct VkWaylandSurfaceCreateInfoKHR From 3573c5a890b4878bb7357f71daaf49260c6fef15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 25 Mar 2024 21:00:08 +0100 Subject: [PATCH 130/137] Wayland: Fix segfault when there is no seat Bug encountered running on a headless instance of Weston. Fixes #2517 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/wl_init.c | 13 +++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index c4c74ade..e04a68c3 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -48,6 +48,7 @@ video tutorials. - Andrew Corrigan - Bailey Cosier - Noel Cower + - James Cowgill - CuriouserThing - Bill Currie - Jason Daly diff --git a/README.md b/README.md index 825329ca..4bccdb29 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ information on what to include when reporting a bug. - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond the limit of the mouse button tokens to be reported (#2423) - [Wayland] Bugfix: The fractional scaling related objects were not destroyed + - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` diff --git a/src/wl_init.c b/src/wl_init.c index 025d46e5..76054bc6 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -137,6 +137,13 @@ static void registryHandleGlobal(void* userData, wl_registry_bind(registry, name, &wl_seat_interface, _glfw_min(4, version)); _glfwAddSeatListenerWayland(_glfw.wl.seat); + + if (wl_seat_get_version(_glfw.wl.seat) >= + WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) + { + _glfw.wl.keyRepeatTimerfd = + timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); + } } } else if (strcmp(interface, "wl_data_device_manager") == 0) @@ -853,12 +860,6 @@ int _glfwInitWayland(void) } } - if (wl_seat_get_version(_glfw.wl.seat) >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) - { - _glfw.wl.keyRepeatTimerfd = - timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); - } - if (!_glfw.wl.wmBase) { _glfwInputError(GLFW_PLATFORM_ERROR, From 228e58262e18f2ee61799bd86d0be718b1e31f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 25 Mar 2024 21:02:10 +0100 Subject: [PATCH 131/137] EGL: Allow native access with defaults on Wayland The intent of enforcing GLFW_EGL_CONTEXT_API for EGL native access functions was to ensure that the application had requested the same context creation API at window creation time that it then attempted native access for. With the 3.4 ABI this both isn't true anymore, as a single binary may have multiple meanings of GLFW_NATIVE_CONTEXT_API, and is no longer necessary, since glfwGetPlatform provides enough information to disambiguate even without knowing what GLFW_PLATFORM was set to. This all leaves the requirement that the context creation API be GLFW_EGL_CONTEXT_API as just an unnecessary annoyance. Fixes #2518 --- CONTRIBUTORS.md | 1 + README.md | 2 ++ src/egl_context.c | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e04a68c3..1371aedb 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -33,6 +33,7 @@ video tutorials. - Nicolas Caramelli - David Carlier - Arturo Castro + - Jose Luis Cercós Pita - Chi-kwan Chan - Victor Chernyakin - TheChocolateOre diff --git a/README.md b/README.md index 4bccdb29..2718e45e 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` + - [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to + `GLFW_NATIVE_CONTEXT_API` (#2518) ## Contact diff --git a/src/egl_context.c b/src/egl_context.c index b901c1be..517c64cb 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -915,8 +915,12 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) if (window->context.source != GLFW_EGL_CONTEXT_API) { - _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return EGL_NO_CONTEXT; + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND || + window->context.source != GLFW_NATIVE_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return EGL_NO_CONTEXT; + } } return window->context.egl.handle; @@ -931,8 +935,12 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) if (window->context.source != GLFW_EGL_CONTEXT_API) { - _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return EGL_NO_SURFACE; + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND || + window->context.source != GLFW_NATIVE_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return EGL_NO_CONTEXT; + } } return window->context.egl.surface; From 8b574030a847febcf90f365a9084dec1f2157d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 7 Apr 2024 19:26:01 +0200 Subject: [PATCH 132/137] Cocoa: Remove support for OS X 10.10 Yosemite Fixes #2506 --- .github/workflows/build.yml | 2 +- README.md | 3 ++- include/GLFW/glfw3.h | 4 ++-- src/cocoa_monitor.m | 6 +++--- src/cocoa_window.m | 6 ------ src/nsgl_context.m | 5 +---- 6 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e980c547..8ef9ed79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,7 +54,7 @@ jobs: timeout-minutes: 4 env: CFLAGS: -Werror - MACOSX_DEPLOYMENT_TARGET: 10.8 + MACOSX_DEPLOYMENT_TARGET: 10.11 CMAKE_OSX_ARCHITECTURES: x86_64;arm64 steps: - uses: actions/checkout@v4 diff --git a/README.md b/README.md index 2718e45e..ca8850e9 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ more information. ## System requirements -GLFW supports Windows XP and later and macOS 10.8 and later. Linux and other +GLFW supports Windows XP and later and macOS 10.11 and later. Linux and other Unix-like systems running the X Window System are supported even without a desktop environment or modern extensions, although some features require a running window or clipboard manager. The OSMesa backend requires Mesa 6.3. @@ -123,6 +123,7 @@ information on what to include when reporting a bug. - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond the limit of the mouse button tokens to be reported (#2423) + - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Wayland] Bugfix: The fractional scaling related objects were not destroyed - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index bed739dc..79b06288 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -3183,8 +3183,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/ * - * @remark @macos On OS X 10.10 and later the window frame will not be rendered - * at full resolution on Retina displays unless the + * @remark @macos The window frame will not be rendered at full resolution on + * Retina displays unless the * [GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) * hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the * application bundle's `Info.plist`. For more information, see diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 1abf6ff5..6495e1f3 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -137,7 +137,7 @@ static GLFWbool modeIsGood(CGDisplayModeRef mode) if (flags & kDisplayModeStretchedFlag) return GLFW_FALSE; -#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100 +#if MAC_OS_X_VERSION_MAX_ALLOWED == 101100 CFStringRef format = CGDisplayModeCopyPixelEncoding(mode); if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) && CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0)) @@ -164,7 +164,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode, if (result.refreshRate == 0) result.refreshRate = (int) round(fallbackRefreshRate); -#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100 +#if MAC_OS_X_VERSION_MAX_ALLOWED == 101100 CFStringRef format = CGDisplayModeCopyPixelEncoding(mode); if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0) { @@ -180,7 +180,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode, result.blueBits = 8; } -#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100 +#if MAC_OS_X_VERSION_MAX_ALLOWED == 101100 CFRelease(format); #endif /* MAC_OS_X_VERSION_MAX_ALLOWED */ return result; diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 780bc7d3..97626a90 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -310,7 +310,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; - (void)windowDidChangeOcclusionState:(NSNotification* )notification { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090 if ([window->ns.object respondsToSelector:@selector(occlusionState)]) { if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible) @@ -318,7 +317,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; else window->ns.occluded = GLFW_TRUE; } -#endif } @end @@ -1950,7 +1948,6 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, { @autoreleasepool { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100 // HACK: Dynamically load Core Animation to avoid adding an extra // dependency for the majority who don't use MoltenVK NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"]; @@ -2027,9 +2024,6 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, } return err; -#else - return VK_ERROR_EXTENSION_NOT_PRESENT; -#endif } // autoreleasepool } diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 57f117ba..e728fc6e 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -218,14 +218,11 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, ADD_ATTRIB(kCGLPFASupportsAutomaticGraphicsSwitching); } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 if (ctxconfig->major >= 4) { SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core); } - else -#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ - if (ctxconfig->major >= 3) + else if (ctxconfig->major >= 3) { SET_ATTRIB(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core); } From 97892c60373f2e3c12e3f119d3788ad38a18c170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 7 Apr 2024 19:39:52 +0200 Subject: [PATCH 133/137] Cocoa: Add QuartzCore as a link-time dependency --- README.md | 1 + docs/build.md | 6 +++--- src/CMakeLists.txt | 5 +++-- src/cocoa_window.m | 14 +++----------- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ca8850e9..9447dcf1 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ information on what to include when reporting a bug. - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond the limit of the mouse button tokens to be reported (#2423) + - [Cocoa] Added `QuartzCore` framework as link-time dependency - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Wayland] Bugfix: The fractional scaling related objects were not destroyed - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) diff --git a/docs/build.md b/docs/build.md index ab4b6817..7b0f8bfe 100644 --- a/docs/build.md +++ b/docs/build.md @@ -390,8 +390,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 and IOKit frameworks to the project as dependencies. They can all be -found in `/System/Library/Frameworks`. +OpenGL, IOKit and QuartzCore frameworks to the project as dependencies. They +can all be found in `/System/Library/Frameworks`. ### With command-line or makefile on macOS {#build_link_osx} @@ -405,7 +405,7 @@ command-line yourself using the `-l` and `-framework` switches. If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do: ```sh -cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit +cc -o myprog myprog.c -lglfw -framework Cocoa -framework OpenGL -framework IOKit -framework QuartzCore ``` If you are using the static library, named `libglfw3.a`, substitute `-lglfw3` diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1057a6f9..463b898d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -151,10 +151,11 @@ endif() if (GLFW_BUILD_COCOA) target_link_libraries(glfw PRIVATE "-framework Cocoa" "-framework IOKit" - "-framework CoreFoundation") + "-framework CoreFoundation" + "-framework QuartzCore") set(glfw_PKG_DEPS "") - set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation") + set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation -framework QuartzCore") endif() if (GLFW_BUILD_WAYLAND) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 97626a90..e69b5fe0 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -28,6 +28,8 @@ #if defined(_GLFW_COCOA) +#import + #include #include #include @@ -1948,18 +1950,8 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, { @autoreleasepool { - // HACK: Dynamically load Core Animation to avoid adding an extra - // dependency for the majority who don't use MoltenVK - NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"]; - if (!bundle) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to find QuartzCore.framework"); - return VK_ERROR_EXTENSION_NOT_PRESENT; - } - // NOTE: Create the layer here as makeBackingLayer should not return nil - window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer]; + window->ns.layer = [CAMetalLayer layer]; if (!window->ns.layer) { _glfwInputError(GLFW_PLATFORM_ERROR, From dfebad786d2bc00b2d63ff71b3fbeb75a1e513d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 7 Apr 2024 20:03:37 +0200 Subject: [PATCH 134/137] Update macOS OpenGL compatibility notes --- docs/compat.md | 35 +++++++++++++++++++---------------- src/nsgl_context.m | 8 ++++---- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/docs/compat.md b/docs/compat.md index ef64b0cc..5072d5c1 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -242,24 +242,27 @@ extensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect. ## OpenGL on macOS {#compat_osx} -Support for OpenGL 3.2 and above was introduced with OS X 10.7 and even then -only forward-compatible, core profile contexts are supported. Support for -OpenGL 4.1 was introduced with OS X 10.9, also limited to forward-compatible, -core profile contexts. There is also still no mechanism for requesting debug -contexts or no-error contexts. Versions of Mac OS X earlier than 10.7 support -at most OpenGL version 2.1. +macOS (as of version 14) still provides OpenGL but it has been deprecated by +Apple. While the API is still available, it is poorly maintained and frequently +develops new issues. On modern systems, OpenGL is implemented on top of Metal +and is not fully thread-safe. -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_PROFILE` hint must be set to -`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The -`GLFW_CONTEXT_DEBUG` and `GLFW_CONTEXT_NO_ERROR` hints are ignored. +macOS does not support OpenGL stereo rendering. If the `GLFW_STEREO` hint is +set to true, OpenGL context creation will always fail. -Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and -`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1, -setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to -a non-default value will cause @ref glfwCreateWindow to fail and the -`GLFW_CONTEXT_DEBUG` hint is ignored. +macOS only supports OpenGL core profile contexts that are forward-compatible, +but the `GLFW_OPENGL_FORWARD_COMPAT` hint is ignored since GLFW 3.4. Even if +this hint is set to false (the default), a forward-compatible context will be +returned if available. + +macOS does not support OpenGL debug contexts, no-error contexts or robustness. +The `GLFW_CONTEXT_DEBUG`, `GLFW_CONTEXT_NO_ERROR` and `GLFW_CONTEXT_ROBUSTNESS` +hints will be ignored and a context without these features will be returned. + +macOS does not flush OpenGL contexts when they are made non-current. The +`GLFW_CONTEXT_RELEASE_BEHAVIOR` hint is ignored and the release behavior will +always be the equivalent of `GLFW_RELEASE_BEHAVIOR_NONE`. If you need a context +to be flushed, call `glFlush` before making it non-current. ## Vulkan loader and API {#compat_vulkan} diff --git a/src/nsgl_context.m b/src/nsgl_context.m index e728fc6e..df729800 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -183,16 +183,16 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, return GLFW_FALSE; } - // Context robustness modes (GL_KHR_robustness) are not yet supported by + // Context robustness modes (GL_KHR_robustness) are not supported by // macOS but are not a hard constraint, so ignore and continue - // Context release behaviors (GL_KHR_context_flush_control) are not yet + // Context release behaviors (GL_KHR_context_flush_control) are not // supported by macOS but are not a hard constraint, so ignore and continue - // Debug contexts (GL_KHR_debug) are not yet supported by macOS but are not + // Debug contexts (GL_KHR_debug) are not supported by macOS but are not // a hard constraint, so ignore and continue - // No-error contexts (GL_KHR_no_error) are not yet supported by macOS but + // No-error contexts (GL_KHR_no_error) are not supported by macOS but // are not a hard constraint, so ignore and continue #define ADD_ATTRIB(a) \ From 51b6434ac46a3a8b852679486f57b5e924b312dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 8 Apr 2024 18:50:08 +0200 Subject: [PATCH 135/137] Wayland: Fix possible segfault on drag enter Found with Clang static analysis. --- README.md | 1 + src/wl_window.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9447dcf1..10044faf 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ information on what to include when reporting a bug. - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Wayland] Bugfix: The fractional scaling related objects were not destroyed - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) + - [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault - [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface` - [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless` - [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to diff --git a/src/wl_window.c b/src/wl_window.c index dc7dcd07..7ace6b4b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1986,7 +1986,7 @@ static void dataDeviceHandleEnter(void* userData, window = wl_surface_get_user_data(surface); } - if (surface == window->wl.surface && _glfw.wl.offers[i].text_uri_list) + if (window && surface == window->wl.surface && _glfw.wl.offers[i].text_uri_list) { _glfw.wl.dragOffer = offer; _glfw.wl.dragFocus = window; From 64906f8e64c873399025fc78133e8616173713cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 8 Apr 2024 18:50:08 +0200 Subject: [PATCH 136/137] Wayland: Cleanup --- src/wl_window.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 7ace6b4b..96f80399 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1974,41 +1974,41 @@ static void dataDeviceHandleEnter(void* userData, _glfw.wl.dragFocus = NULL; } - for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) + unsigned int i; + + for (i = 0; i < _glfw.wl.offerCount; i++) { if (_glfw.wl.offers[i].offer == offer) + break; + } + + if (i == _glfw.wl.offerCount) + return; + + if (surface && wl_proxy_get_tag((struct wl_proxy*) surface) == &_glfw.wl.tag) + { + _GLFWwindow* window = wl_surface_get_user_data(surface); + if (window->wl.surface == surface) { - _GLFWwindow* window = NULL; - - if (surface) - { - if (wl_proxy_get_tag((struct wl_proxy*) surface) == &_glfw.wl.tag) - window = wl_surface_get_user_data(surface); - } - - if (window && surface == window->wl.surface && _glfw.wl.offers[i].text_uri_list) + if (_glfw.wl.offers[i].text_uri_list) { _glfw.wl.dragOffer = offer; _glfw.wl.dragFocus = window; _glfw.wl.dragSerial = serial; - } - _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1]; - _glfw.wl.offerCount--; - break; + wl_data_offer_accept(offer, serial, "text/uri-list"); + } } } - if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag) - return; - - if (_glfw.wl.dragOffer) - wl_data_offer_accept(offer, serial, "text/uri-list"); - else + if (!_glfw.wl.dragOffer) { wl_data_offer_accept(offer, serial, NULL); wl_data_offer_destroy(offer); } + + _glfw.wl.offers[i] = _glfw.wl.offers[_glfw.wl.offerCount - 1]; + _glfw.wl.offerCount--; } static void dataDeviceHandleLeave(void* userData, From b35641f4a3c62aa86a0b3c983d163bc0fe36026d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 12 Apr 2024 18:25:19 +0200 Subject: [PATCH 137/137] Wayland: Cleanup --- src/wl_window.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 96f80399..2e842aaa 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2042,15 +2042,17 @@ static void dataDeviceHandleDrop(void* userData, int count; char** paths = _glfwParseUriList(string, &count); if (paths) + { _glfwInputDrop(_glfw.wl.dragFocus, count, (const char**) paths); - for (int i = 0; i < count; i++) - _glfw_free(paths[i]); + for (int i = 0; i < count; i++) + _glfw_free(paths[i]); - _glfw_free(paths); + _glfw_free(paths); + } + + _glfw_free(string); } - - _glfw_free(string); } static void dataDeviceHandleSelection(void* userData,