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 001/112] 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 9d2d504b2..8ed24d981 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 a3cb1fe68..830f8fd9a 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 efd1383f8..876eefa7b 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 d00d676e1..ab4b68173 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 0610202ff..7aa75e31e 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 3be954880..fd93a7129 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 9c55ac9d9..9a6ad6fdf 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 92f0d3244..011b239c8 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 e75a55190..15dc4ec4c 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 2f46dfcbe..c3a58e23e 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 d5de47939..bb86ad226 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 641d5f0b8..75f8ec53f 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 399145542..4d1d66ae0 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 d56f145ff..a153edb38 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 3512e8b6e..8463cbb65 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 0dcf0a38d..5fa360dd3 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 cc1fac4f3..7232dc2ac 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 ef65dd350..06deb76f4 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 7082682be..fae559660 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 532264e16..dbd5a900c 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 7b3b34028..3f8ddb302 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 887335935..76f3ede27 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 07d41d37a..d8a916b08 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 64462b04f..1ea3deb3d 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 270fa4cd8..cd32e5d05 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 ed623680f..99d183309 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 efc286d50..6f802e325 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 daa8367a8..d34cc224c 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 88940fcde..8c10f5e67 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 ec1f6b554..16dc8cf32 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 a2199c560..40a490f90 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 d818f4528..a9b528f03 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 4843a76a1..8222b0dee 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 1db08114f..753260657 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 2f12adf2b..0b9d83a22 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 af1b0f446..9ca64963e 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 75652dcc5..7ce4e015a 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 7d81c6724..b3482d26c 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 b53e36e80..595cf7173 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 4bdd2448d..a0ef39625 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 3c355a53a..bab74d4f2 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 5a5d7b7c3..ce298a8b4 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 a17240847..4d7bd7cea 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 94374adb8..39faa0fc4 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 d9fabdea4..274d21ca2 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 8a23ffc41..209469e26 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 824e383ce..77ab56bab 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 59389a902..6703485e0 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 9ab6438b5..2d8f59d07 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 47c8dff6d..b76599b61 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 87c85b94d..1be43e66b 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 7e3d8845c..a2f868527 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 212e666c2..6e418d7a5 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 dd5948f07..ca96fae22 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 a38e15ddd..4a4b2cbb3 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 ef57a5a6e..f72a5d048 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 e6a9496cd..7d26f0b11 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 1463d1694..8b5d9f340 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 3aff476d3..025d46e5e 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 df30313ae..dca8ebbd4 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 149cd241b..2a843b3c5 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 5b491ffbb..218b4efd0 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 e992f444e..982c526c6 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 38af7e0c0..cab81127c 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 14e363d14..30326c5be 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 e0295465a..601387a9e 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 6b8dfcac6..68767cc36 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 b07408f61..d52748ac2 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 002/112] 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 876eefa7b..050ada3c3 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 003/112] 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 050ada3c3..d2615b174 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 56983b087..3ef1aebe1 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 fd93a7129..148d08712 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 9a6ad6fdf..bed739dcb 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 3f8ddb302..8148a57d9 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 76f3ede27..eae87c730 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 fdc3c1992..ab3b99a7b 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 c81bf0244..ffea5dbfb 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 004/112] 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 d2615b174..77a98ca72 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 218b4efd0..9a411155f 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 005/112] 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 77a98ca72..e514ced3e 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 eae87c730..e36c4455a 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 8222b0dee..dbcb835b8 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 753260657..f31489b04 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 274d21ca2..3f76c5403 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 006/112] 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 e514ced3e..825329ca5 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 06deb76f4..8dbe3caae 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 e36c4455a..ad59efb59 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 f31489b04..f0e1dcc9a 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 007/112] 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 75f8ec53f..150a7477f 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 5fa360dd3..32df0b9e4 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 8dbe3caae..831a9cf7f 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 fae559660..a971585f4 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 d34cc224c..e93eb4d4f 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 0b9d83a22..88f5adb83 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 209469e26..dd92b6f49 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 1be43e66b..d13a90400 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 7d26f0b11..5cd08f689 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 dca8ebbd4..9f56c3ae1 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 9a411155f..812b9e91f 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 cab81127c..8f8e2bcd7 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 601387a9e..fa2d390ff 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 008/112] 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 150a7477f..1abf6ff56 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 32df0b9e4..780bc7d38 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 7232dc2ac..f4fa63ad7 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 831a9cf7f..b901c1bec 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 a971585f4..a2464a9d6 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 8148a57d9..c619eefce 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 6f802e325..cc95efb64 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 e93eb4d4f..57f117bab 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 88f5adb83..0bb375a8b 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 3f76c5403..9c87fcfe1 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 dd92b6f49..1c9189fab 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 d13a90400..87e5c206f 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 5cd08f689..d014944b8 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 8b5d9f340..e03121a46 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 9f56c3ae1..1ec5f5afa 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 812b9e91f..dc7dcd07a 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 8f8e2bcd7..3af827520 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 fa2d390ff..322349f08 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 009/112] 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 ad59efb59..4f097aa82 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 2a843b3c5..f3e8cba2d 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 010/112] 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 c4c74adeb..e04a68c31 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 825329ca5..4bccdb29e 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 025d46e5e..76054bc6a 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 011/112] 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 e04a68c31..1371aedbc 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 4bccdb29e..2718e45e3 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 b901c1bec..517c64cb2 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 012/112] 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 e980c5479..8ef9ed793 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 2718e45e3..ca8850e9d 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 bed739dcb..79b062884 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 1abf6ff56..6495e1f3b 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 780bc7d38..97626a900 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 57f117bab..e728fc6ea 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 013/112] 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 ca8850e9d..9447dcf15 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 ab4b68173..7b0f8bfe6 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 1057a6f98..463b898df 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 97626a900..e69b5fe0c 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 014/112] 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 ef64b0cc3..5072d5c11 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 e728fc6ea..df7298000 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 015/112] 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 9447dcf15..10044faf1 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 dc7dcd07a..7ace6b4bc 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 016/112] 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 7ace6b4bc..96f803999 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 017/112] 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 96f803999..2e842aaaa 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, From 043378876a67b092f5d0d3d9748660121a336dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 9 May 2024 17:18:39 +0200 Subject: [PATCH 018/112] Use CMakePushCheckState for check state management --- src/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 463b898df..7a8726d1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -313,30 +313,34 @@ if (GLFW_BUILD_SHARED_LIBRARY) if (MINGW) # Enable link-time exploit mitigation features enabled by default on MSVC include(CheckCCompilerFlag) + include(CMakePushCheckState) # Compatibility with data execution prevention (DEP) + cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") check_c_compiler_flag("" _GLFW_HAS_DEP) if (_GLFW_HAS_DEP) target_link_libraries(glfw PRIVATE "-Wl,--nxcompat") endif() + cmake_pop_check_state() # Compatibility with address space layout randomization (ASLR) + cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") check_c_compiler_flag("" _GLFW_HAS_ASLR) if (_GLFW_HAS_ASLR) target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase") endif() + cmake_pop_check_state() # Compatibility with 64-bit address space layout randomization (ASLR) + cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va") check_c_compiler_flag("" _GLFW_HAS_64ASLR) if (_GLFW_HAS_64ASLR) target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va") endif() - - # Clear flags again to avoid breaking later tests - set(CMAKE_REQUIRED_FLAGS) + cmake_pop_check_state() endif() if (UNIX) From b850107a32e96ae36dc7b5f88cd337016e356404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 10 May 2024 15:15:12 +0200 Subject: [PATCH 019/112] Update minimum CMake version to 3.16 This replaces some workarounds and manual logic with new features available with CMake 3.16, including list(FILTER), list(JOIN), foreach(IN LISTS) and enable_language(OBJC). Policy settings no longer needed with 3.16 have been removed. Related to #2541 --- CMake/GenerateMappings.cmake | 36 +++++++++++++++++++----------------- CMakeLists.txt | 31 +++---------------------------- README.md | 3 ++- docs/compile.md | 4 ++-- src/CMakeLists.txt | 16 +++------------- 5 files changed, 29 insertions(+), 61 deletions(-) diff --git a/CMake/GenerateMappings.cmake b/CMake/GenerateMappings.cmake index c8c9e23f2..9a95df6d8 100644 --- a/CMake/GenerateMappings.cmake +++ b/CMake/GenerateMappings.cmake @@ -1,6 +1,8 @@ # Usage: # cmake -P GenerateMappings.cmake +cmake_policy(VERSION 3.16) + set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt") set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt") set(template_path "${CMAKE_ARGV3}") @@ -22,24 +24,24 @@ if (status_code) endif() file(STRINGS "${source_path}" lines) -foreach(line ${lines}) - if (line MATCHES "^[0-9a-fA-F]") - if (line MATCHES "platform:Windows") - if (GLFW_WIN32_MAPPINGS) - string(APPEND GLFW_WIN32_MAPPINGS "\n") - endif() - string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",") - elseif (line MATCHES "platform:Mac OS X") - if (GLFW_COCOA_MAPPINGS) - string(APPEND GLFW_COCOA_MAPPINGS "\n") - endif() - string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",") - elseif (line MATCHES "platform:Linux") - if (GLFW_LINUX_MAPPINGS) - string(APPEND GLFW_LINUX_MAPPINGS "\n") - endif() - string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",") +list(FILTER lines INCLUDE REGEX "^[0-9a-fA-F]") + +foreach(line IN LISTS lines) + if (line MATCHES "platform:Windows") + if (GLFW_WIN32_MAPPINGS) + string(APPEND GLFW_WIN32_MAPPINGS "\n") endif() + string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",") + elseif (line MATCHES "platform:Mac OS X") + if (GLFW_COCOA_MAPPINGS) + string(APPEND GLFW_COCOA_MAPPINGS "\n") + endif() + string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",") + elseif (line MATCHES "platform:Linux") + if (GLFW_LINUX_MAPPINGS) + string(APPEND GLFW_LINUX_MAPPINGS "\n") + endif() + string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",") endif() endforeach() diff --git a/CMakeLists.txt b/CMakeLists.txt index 830f8fd9a..398b36eb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,6 @@ -cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR) +cmake_minimum_required(VERSION 3.16...3.28 FATAL_ERROR) -project(GLFW VERSION 3.5.0 LANGUAGES C) - -if (POLICY CMP0069) - cmake_policy(SET CMP0069 NEW) -endif() - -if (POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif() +project(GLFW VERSION 3.5.0 LANGUAGES C HOMEPAGE_URL "https://www.glfw.org/") set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -80,24 +72,7 @@ endif() # This is here because it also applies to tests and examples #-------------------------------------------------------------------- if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL) - if (CMAKE_VERSION VERSION_LESS 3.15) - foreach (flag CMAKE_C_FLAGS - CMAKE_C_FLAGS_DEBUG - CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL - CMAKE_C_FLAGS_RELWITHDEBINFO) - - if (flag MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}") - endif() - if (flag MATCHES "/MDd") - string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}") - endif() - - endforeach() - else() - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() #-------------------------------------------------------------------- diff --git a/README.md b/README.md index 10044faf1..fb77b9ddf 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ in the documentation for more information. ## Dependencies -GLFW itself needs only CMake 3.4 or later and the headers and libraries for your +GLFW itself needs only CMake 3.16 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 @@ -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) + - Updated minimum CMake version to 3.16 (#2541) - [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 diff --git a/docs/compile.md b/docs/compile.md index f8385fefa..6b0b71227 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -264,8 +264,8 @@ __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][] -variable instead of this GLFW-specific option. +It is recommended to set the standard CMake variable [CMAKE_MSVC_RUNTIME_LIBRARY][] +instead of this GLFW-specific option. [CMAKE_MSVC_RUNTIME_LIBRARY]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7a8726d1b..fc4e17cf2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,6 +30,7 @@ add_custom_target(update_mappings set_target_properties(update_mappings PROPERTIES FOLDER "GLFW3") if (GLFW_BUILD_COCOA) + enable_language(OBJC) target_compile_definitions(glfw PRIVATE _GLFW_COCOA) target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m cocoa_joystick.m cocoa_monitor.m cocoa_window.m @@ -137,13 +138,6 @@ target_include_directories(glfw PRIVATE "${GLFW_BINARY_DIR}/src") target_link_libraries(glfw PRIVATE Threads::Threads) -# Workaround for CMake not knowing about .m files before version 3.16 -if (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE) - set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m - cocoa_window.m nsgl_context.m PROPERTIES - LANGUAGE C) -endif() - if (GLFW_BUILD_WIN32) list(APPEND glfw_PKG_LIBS "-lgdi32") endif() @@ -349,12 +343,8 @@ if (GLFW_BUILD_SHARED_LIBRARY) endif() endif() -foreach(arg ${glfw_PKG_DEPS}) - string(APPEND deps " ${arg}") -endforeach() -foreach(arg ${glfw_PKG_LIBS}) - string(APPEND libs " ${arg}") -endforeach() +list(JOIN glfw_PKG_DEPS " " deps) +list(JOIN glfw_PKG_LIBS " " libs) set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL "GLFW pkg-config Requires.private") From a576a56a8d6a3f17569e3d46f85365dc159c7408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 10 May 2024 17:05:49 +0200 Subject: [PATCH 020/112] Remove unused CMake find module for OSMesa --- CMake/modules/FindOSMesa.cmake | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 CMake/modules/FindOSMesa.cmake diff --git a/CMake/modules/FindOSMesa.cmake b/CMake/modules/FindOSMesa.cmake deleted file mode 100644 index 3194bd91a..000000000 --- a/CMake/modules/FindOSMesa.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# Try to find OSMesa on a Unix system -# -# This will define: -# -# OSMESA_LIBRARIES - Link these to use OSMesa -# OSMESA_INCLUDE_DIR - Include directory for OSMesa -# -# Copyright (c) 2014 Brandon Schaefer - -if (NOT WIN32) - - find_package (PkgConfig) - pkg_check_modules (PKG_OSMESA QUIET osmesa) - - set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS}) - set (OSMESA_LIBRARIES ${PKG_OSMESA_LIBRARIES}) - -endif () From 21fea01161e0d6b70c0c5c1f52dc8e7a7df14a50 Mon Sep 17 00:00:00 2001 From: LocalSpook Date: Sun, 10 Dec 2023 05:54:11 -0700 Subject: [PATCH 021/112] Wayland: Replace _glfwKeySym2Unicode with xkbcommon libxkbcommon already provides functions to convert keysyms to codepoints and UTF-8. The library has offered these functions since 0.5.0[1], so using them won't cause any compatibility problems. [1] https://xkbcommon.org/doc/0.5.0/group__keysyms.html Closes #2444 --- src/CMakeLists.txt | 4 ++-- src/wl_init.c | 4 ++++ src/wl_platform.h | 7 ++++++- src/wl_window.c | 28 ++++++++++++++-------------- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc4e17cf2..1a085b2b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,8 +53,8 @@ endif() if (GLFW_BUILD_WAYLAND) target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND) - target_sources(glfw PRIVATE wl_platform.h xkb_unicode.h wl_init.c - wl_monitor.c wl_window.c xkb_unicode.c) + target_sources(glfw PRIVATE wl_platform.h wl_init.c + wl_monitor.c wl_window.c) endif() if (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND) diff --git a/src/wl_init.c b/src/wl_init.c index 76054bc6a..ef9e45036 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -711,6 +711,10 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_compose_state_get_status"); _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"); + _glfw.wl.xkb.keysym_to_utf32 = (PFN_xkb_keysym_to_utf32) + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keysym_to_utf32"); + _glfw.wl.xkb.keysym_to_utf8 = (PFN_xkb_keysym_to_utf8) + _glfwPlatformGetModuleSymbol(_glfw.wl.xkb.handle, "xkb_keysym_to_utf8"); if (!_glfw.wl.xkb.context_new || !_glfw.wl.xkb.context_unref || diff --git a/src/wl_platform.h b/src/wl_platform.h index f3e8cba2d..afa6f50af 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -42,7 +42,6 @@ typedef struct VkWaylandSurfaceCreateInfoKHR typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*); -#include "xkb_unicode.h" #include "posix_poll.h" typedef int (* PFN_wl_display_flush)(struct wl_display* display); @@ -178,6 +177,8 @@ typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, con typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t); typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t); typedef int (* PFN_xkb_state_mod_index_is_active)(struct xkb_state*,xkb_mod_index_t,enum xkb_state_component); +typedef uint32_t (* PFN_xkb_keysym_to_utf32)(xkb_keysym_t); +typedef int (* PFN_xkb_keysym_to_utf8)(xkb_keysym_t, char*, size_t); #define xkb_context_new _glfw.wl.xkb.context_new #define xkb_context_unref _glfw.wl.xkb.context_unref #define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string @@ -191,6 +192,8 @@ typedef int (* PFN_xkb_state_mod_index_is_active)(struct xkb_state*,xkb_mod_inde #define xkb_state_update_mask _glfw.wl.xkb.state_update_mask #define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout #define xkb_state_mod_index_is_active _glfw.wl.xkb.state_mod_index_is_active +#define xkb_keysym_to_utf32 _glfw.wl.xkb.keysym_to_utf32 +#define xkb_keysym_to_utf8 _glfw.wl.xkb.keysym_to_utf8 typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags); typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*); @@ -495,6 +498,8 @@ typedef struct _GLFWlibraryWayland PFN_xkb_state_update_mask state_update_mask; PFN_xkb_state_key_get_layout state_key_get_layout; PFN_xkb_state_mod_index_is_active state_mod_index_is_active; + PFN_xkb_keysym_to_utf32 keysym_to_utf32; + PFN_xkb_keysym_to_utf8 keysym_to_utf8; PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale; PFN_xkb_compose_table_unref compose_table_unref; diff --git a/src/wl_window.c b/src/wl_window.c index 2e842aaaa..72c1a4026 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1192,8 +1192,8 @@ static void inputText(_GLFWwindow* window, uint32_t scancode) if (xkb_state_key_get_syms(_glfw.wl.xkb.state, keycode, &keysyms) == 1) { const xkb_keysym_t keysym = composeSymbol(keysyms[0]); - const uint32_t codepoint = _glfwKeySym2Unicode(keysym); - if (codepoint != GLFW_INVALID_CODEPOINT) + const uint32_t codepoint = xkb_keysym_to_utf32(keysym); + if (codepoint != 0) { const int mods = _glfw.wl.xkb.modifiers; const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT)); @@ -2721,23 +2721,23 @@ const char* _glfwGetScancodeNameWayland(int scancode) return NULL; } - const uint32_t codepoint = _glfwKeySym2Unicode(keysyms[0]); - if (codepoint == GLFW_INVALID_CODEPOINT) + // WORKAROUND: xkb_keysym_to_utf8() requires the third parameter (size of the output buffer) + // to be at least 7 (6 bytes + a null terminator), because it was written when UTF-8 + // sequences could be up to 6 bytes long. The _glfw.wl.keynames buffers are only 5 bytes + // long, because UTF-8 sequences are now limited to 4 bytes and no codepoints were ever assigned + // that needed more than that. To work around this, we first copy to a temporary buffer. + // + // See: https://github.com/xkbcommon/libxkbcommon/issues/418 + char temp_buffer[7]; + const int bytes_written = xkb_keysym_to_utf8(keysyms[0], temp_buffer, sizeof(temp_buffer)); + if (bytes_written <= 0 || bytes_written > 5) { _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to retrieve codepoint for key name"); + "Wayland: Failed to encode keysym as UTF-8"); return NULL; } + memcpy(_glfw.wl.keynames[key], temp_buffer, bytes_written); - const size_t count = _glfwEncodeUTF8(_glfw.wl.keynames[key], codepoint); - if (count == 0) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Failed to encode codepoint for key name"); - return NULL; - } - - _glfw.wl.keynames[key][count] = '\0'; return _glfw.wl.keynames[key]; } From cf4734ce8a5fbdfc3623f3842bafd2437045d8e1 Mon Sep 17 00:00:00 2001 From: er-azh <80633916+er-azh@users.noreply.github.com> Date: Thu, 25 Jul 2024 03:17:43 -0400 Subject: [PATCH 022/112] X11: Fix detectEWMH not releasing error handler If detectEWMH failed to query the EWMH helper window, it would return without restoring the previous Xlib error handler. This was bad (because other code might also be using the facility) and bad (because GLFW would assert the next time it tried to grab the error handler). This commit adds the necessary release call. Closes #2593 Fixes #2601 Closes #2631 --- src/x11_init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/x11_init.c b/src/x11_init.c index 982c526c6..6b34c2639 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -535,6 +535,7 @@ static void detectEWMH(void) XA_WINDOW, (unsigned char**) &windowFromChild)) { + _glfwReleaseErrorHandlerX11(); XFree(windowFromRoot); return; } From e7ea71be039836da3a98cea55ae5569cb5eb885c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 12 Jan 2025 19:29:05 +0100 Subject: [PATCH 023/112] Update changelog and add credit Related to #2593 --- CONTRIBUTORS.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1371aedbc..4fc27126d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -67,6 +67,7 @@ video tutorials. - Robin Eklind - Jan Ekström - Siavash Eliasi + - er-azh - Ahmad Fatoum - Nikita Fediuchin - Felipe Ferreira diff --git a/README.md b/README.md index fb77b9ddf..523061885 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ information on what to include when reporting a bug. - [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 + - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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 From d30d63313c5876f9ce8770f79cd59dd7109a768e Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sat, 5 Jul 2025 19:12:15 +0200 Subject: [PATCH 024/112] Examples: disable MSVC warning C5287 in nuklear.h Latest MSVC has a warning `operands are different enum types` which this disables until upstream nuklear fixes this --- deps/nuklear.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deps/nuklear.h b/deps/nuklear.h index f2eb9dfa2..0f534e52a 100644 --- a/deps/nuklear.h +++ b/deps/nuklear.h @@ -423,6 +423,11 @@ NK_STATIC_ASSERT(sizeof(nk_rune) >= 4); NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*)); NK_STATIC_ASSERT(sizeof(nk_ptr) >= sizeof(void*)); +#if defined(_MSC_VER) +/* disable `operands are different enum types` warning on MSVC */ +#pragma warning( disable: 5287 ) +#endif + /* ============================================================================ * * API From 506c11ba43b901dbcc4d90449f46de67cf000af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=BCrkamp?= Date: Sat, 5 Jul 2025 19:16:08 +0200 Subject: [PATCH 025/112] Wayland: Ignore key repeat events when no window has keyboard focus (#2732) * Wayland: Ignore key repeat events when no window has keyboard focus --- CONTRIBUTORS.md | 2 +- README.md | 1 + src/wl_window.c | 20 ++++++++++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4fc27126d..8fa1cb724 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -229,7 +229,7 @@ video tutorials. - Brandon Schaefer - Sebastian Schuberth - Scr3amer - - Jan Schuerkamp + - Jan Schürkamp - Christian Sdunek - Matt Sealey - Steve Sexton diff --git a/README.md b/README.md index 523061885..9d78ecdad 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ information on what to include when reporting a bug. - [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 + - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_window.c b/src/wl_window.c index 72c1a4026..6457f31e0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1267,17 +1267,21 @@ static void handleEvents(double* timeout) if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8) { - for (uint64_t i = 0; i < repeats; i++) + if(_glfw.wl.keyboardFocus) { - _glfwInputKey(_glfw.wl.keyboardFocus, - translateKey(_glfw.wl.keyRepeatScancode), - _glfw.wl.keyRepeatScancode, - GLFW_PRESS, - _glfw.wl.xkb.modifiers); - inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); + for (uint64_t i = 0; i < repeats; i++) + { + _glfwInputKey(_glfw.wl.keyboardFocus, + translateKey(_glfw.wl.keyRepeatScancode), + _glfw.wl.keyRepeatScancode, + GLFW_PRESS, + _glfw.wl.xkb.modifiers); + inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); + } + + event = GLFW_TRUE; } - event = GLFW_TRUE; } } From d1b87143bcdf20eb0007965ea5d1230264780d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 4 Apr 2024 17:00:46 +0200 Subject: [PATCH 026/112] Win32: Remove support for original MinGW The original MinGW distribution appears to no longer be maintained and should not be used. Anyone still using MinGW should consider switching to the MinGW-w64 fork or another actively maintained toolchain. MinGW-w64 supports 64-bit binaries and provides much newer compilers and Win32 headers. Fixes #2540 --- .appveyor.yml | 2 +- .editorconfig | 6 - README.md | 3 +- deps/mingw/_mingw_dxhelper.h | 117 -- deps/mingw/dinput.h | 2467 ---------------------------------- deps/mingw/xinput.h | 239 ---- docs/compile.md | 24 +- docs/intro.md | 6 +- docs/news.md | 9 + src/CMakeLists.txt | 22 - src/platform.c | 2 - src/win32_platform.h | 15 - 12 files changed, 27 insertions(+), 2885 deletions(-) delete mode 100644 deps/mingw/_mingw_dxhelper.h delete mode 100644 deps/mingw/dinput.h delete mode 100644 deps/mingw/xinput.h diff --git a/.appveyor.yml b/.appveyor.yml index c58911ccf..fe48c8268 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -29,7 +29,7 @@ for: only: - GENERATOR: MinGW Makefiles build_script: - - set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin% + - set PATH=C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH:C:\Program Files\Git\usr\bin=% - cmake -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% - cmake --build build - diff --git a/.editorconfig b/.editorconfig index 2b44e7b2e..bbdd90186 100644 --- a/.editorconfig +++ b/.editorconfig @@ -41,12 +41,6 @@ indent_size = 2 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 diff --git a/README.md b/README.md index 9d78ecdad..344d61954 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ 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++ 2013 and later, MinGW and +GLFW supports compilation on Windows with Visual C++ (2013 and later) 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. @@ -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) - Updated minimum CMake version to 3.16 (#2541) + - Removed support for building with original MinGW (#2540) - [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 diff --git a/deps/mingw/_mingw_dxhelper.h b/deps/mingw/_mingw_dxhelper.h deleted file mode 100644 index 849e29146..000000000 --- a/deps/mingw/_mingw_dxhelper.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the mingw-w64 runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. - */ - -#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS) -#define NONAMELESSUNION 1 -#endif -#if defined(NONAMELESSSTRUCT) && \ - !defined(NONAMELESSUNION) -#define NONAMELESSUNION 1 -#endif -#if defined(NONAMELESSUNION) && \ - !defined(NONAMELESSSTRUCT) -#define NONAMELESSSTRUCT 1 -#endif -#if !defined(__GNU_EXTENSION) -#if defined(__GNUC__) || defined(__GNUG__) -#define __GNU_EXTENSION __extension__ -#else -#define __GNU_EXTENSION -#endif -#endif /* __extension__ */ - -#ifndef __ANONYMOUS_DEFINED -#define __ANONYMOUS_DEFINED -#if defined(__GNUC__) || defined(__GNUG__) -#define _ANONYMOUS_UNION __extension__ -#define _ANONYMOUS_STRUCT __extension__ -#else -#define _ANONYMOUS_UNION -#define _ANONYMOUS_STRUCT -#endif -#ifndef NONAMELESSUNION -#define _UNION_NAME(x) -#define _STRUCT_NAME(x) -#else /* NONAMELESSUNION */ -#define _UNION_NAME(x) x -#define _STRUCT_NAME(x) x -#endif -#endif /* __ANONYMOUS_DEFINED */ - -#ifndef DUMMYUNIONNAME -# ifdef NONAMELESSUNION -# define DUMMYUNIONNAME u -# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */ -# define DUMMYUNIONNAME2 u2 -# define DUMMYUNIONNAME3 u3 -# define DUMMYUNIONNAME4 u4 -# define DUMMYUNIONNAME5 u5 -# define DUMMYUNIONNAME6 u6 -# define DUMMYUNIONNAME7 u7 -# define DUMMYUNIONNAME8 u8 -# define DUMMYUNIONNAME9 u9 -# else /* NONAMELESSUNION */ -# define DUMMYUNIONNAME -# define DUMMYUNIONNAME1 /* Wine uses this variant */ -# define DUMMYUNIONNAME2 -# define DUMMYUNIONNAME3 -# define DUMMYUNIONNAME4 -# define DUMMYUNIONNAME5 -# define DUMMYUNIONNAME6 -# define DUMMYUNIONNAME7 -# define DUMMYUNIONNAME8 -# define DUMMYUNIONNAME9 -# endif -#endif /* DUMMYUNIONNAME */ - -#if !defined(DUMMYUNIONNAME1) /* MinGW does not define this one */ -# ifdef NONAMELESSUNION -# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */ -# else -# define DUMMYUNIONNAME1 /* Wine uses this variant */ -# endif -#endif /* DUMMYUNIONNAME1 */ - -#ifndef DUMMYSTRUCTNAME -# ifdef NONAMELESSUNION -# define DUMMYSTRUCTNAME s -# define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */ -# define DUMMYSTRUCTNAME2 s2 -# define DUMMYSTRUCTNAME3 s3 -# define DUMMYSTRUCTNAME4 s4 -# define DUMMYSTRUCTNAME5 s5 -# else -# define DUMMYSTRUCTNAME -# define DUMMYSTRUCTNAME1 /* Wine uses this variant */ -# define DUMMYSTRUCTNAME2 -# define DUMMYSTRUCTNAME3 -# define DUMMYSTRUCTNAME4 -# define DUMMYSTRUCTNAME5 -# endif -#endif /* DUMMYSTRUCTNAME */ - -/* These are for compatibility with the Wine source tree */ - -#ifndef WINELIB_NAME_AW -# ifdef __MINGW_NAME_AW -# define WINELIB_NAME_AW __MINGW_NAME_AW -# else -# ifdef UNICODE -# define WINELIB_NAME_AW(func) func##W -# else -# define WINELIB_NAME_AW(func) func##A -# endif -# endif -#endif /* WINELIB_NAME_AW */ - -#ifndef DECL_WINELIB_TYPE_AW -# ifdef __MINGW_TYPEDEF_AW -# define DECL_WINELIB_TYPE_AW __MINGW_TYPEDEF_AW -# else -# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type; -# endif -#endif /* DECL_WINELIB_TYPE_AW */ - diff --git a/deps/mingw/dinput.h b/deps/mingw/dinput.h deleted file mode 100644 index b5754802b..000000000 --- a/deps/mingw/dinput.h +++ /dev/null @@ -1,2467 +0,0 @@ -/* - * Copyright (C) the Wine project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef __DINPUT_INCLUDED__ -#define __DINPUT_INCLUDED__ - -#define COM_NO_WINDOWS_H -#include -#include <_mingw_dxhelper.h> - -#ifndef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#endif - -/* Classes */ -DEFINE_GUID(CLSID_DirectInput, 0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(CLSID_DirectInputDevice, 0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(CLSID_DirectInput8, 0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(CLSID_DirectInputDevice8, 0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/* Interfaces */ -DEFINE_GUID(IID_IDirectInputA, 0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputW, 0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput2A, 0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput2W, 0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput7A, 0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInput7W, 0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInput8A, 0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); -DEFINE_GUID(IID_IDirectInput8W, 0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); -DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice2A, 0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice2W, 0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice7A, 0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInputDevice7W, 0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInputDevice8A, 0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); -DEFINE_GUID(IID_IDirectInputDevice8W, 0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); -DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); - -/* Predefined object types */ -DEFINE_GUID(GUID_XAxis, 0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_YAxis, 0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_ZAxis, 0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RxAxis,0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RyAxis,0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RzAxis,0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Slider,0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Button,0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Key, 0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_POV, 0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Unknown,0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/* Predefined product GUIDs */ -DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboard, 0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Joystick, 0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysMouseEm, 0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysMouseEm2, 0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboardEm, 0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/* predefined forcefeedback effects */ -DEFINE_GUID(GUID_ConstantForce, 0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_RampForce, 0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Square, 0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Sine, 0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Triangle, 0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_SawtoothUp, 0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Spring, 0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Damper, 0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Inertia, 0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Friction, 0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_CustomForce, 0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); - -typedef struct IDirectInputA *LPDIRECTINPUTA; -typedef struct IDirectInputW *LPDIRECTINPUTW; -typedef struct IDirectInput2A *LPDIRECTINPUT2A; -typedef struct IDirectInput2W *LPDIRECTINPUT2W; -typedef struct IDirectInput7A *LPDIRECTINPUT7A; -typedef struct IDirectInput7W *LPDIRECTINPUT7W; -#if DIRECTINPUT_VERSION >= 0x0800 -typedef struct IDirectInput8A *LPDIRECTINPUT8A; -typedef struct IDirectInput8W *LPDIRECTINPUT8W; -#endif /* DI8 */ -typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA; -typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW; -#if DIRECTINPUT_VERSION >= 0x0500 -typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A; -typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W; -#endif /* DI5 */ -#if DIRECTINPUT_VERSION >= 0x0700 -typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A; -typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W; -#endif /* DI7 */ -#if DIRECTINPUT_VERSION >= 0x0800 -typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A; -typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W; -#endif /* DI8 */ -#if DIRECTINPUT_VERSION >= 0x0500 -typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT; -#endif /* DI5 */ -typedef struct SysKeyboardA *LPSYSKEYBOARDA; -typedef struct SysMouseA *LPSYSMOUSEA; - -#define IID_IDirectInput WINELIB_NAME_AW(IID_IDirectInput) -#define IDirectInput WINELIB_NAME_AW(IDirectInput) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUT) -#define IID_IDirectInput2 WINELIB_NAME_AW(IID_IDirectInput2) -#define IDirectInput2 WINELIB_NAME_AW(IDirectInput2) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUT2) -#define IID_IDirectInput7 WINELIB_NAME_AW(IID_IDirectInput7) -#define IDirectInput7 WINELIB_NAME_AW(IDirectInput7) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUT7) -#if DIRECTINPUT_VERSION >= 0x0800 -#define IID_IDirectInput8 WINELIB_NAME_AW(IID_IDirectInput8) -#define IDirectInput8 WINELIB_NAME_AW(IDirectInput8) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUT8) -#endif /* DI8 */ -#define IID_IDirectInputDevice WINELIB_NAME_AW(IID_IDirectInputDevice) -#define IDirectInputDevice WINELIB_NAME_AW(IDirectInputDevice) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE) -#if DIRECTINPUT_VERSION >= 0x0500 -#define IID_IDirectInputDevice2 WINELIB_NAME_AW(IID_IDirectInputDevice2) -#define IDirectInputDevice2 WINELIB_NAME_AW(IDirectInputDevice2) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE2) -#endif /* DI5 */ -#if DIRECTINPUT_VERSION >= 0x0700 -#define IID_IDirectInputDevice7 WINELIB_NAME_AW(IID_IDirectInputDevice7) -#define IDirectInputDevice7 WINELIB_NAME_AW(IDirectInputDevice7) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE7) -#endif /* DI7 */ -#if DIRECTINPUT_VERSION >= 0x0800 -#define IID_IDirectInputDevice8 WINELIB_NAME_AW(IID_IDirectInputDevice8) -#define IDirectInputDevice8 WINELIB_NAME_AW(IDirectInputDevice8) -DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE8) -#endif /* DI8 */ - -#define DI_OK S_OK -#define DI_NOTATTACHED S_FALSE -#define DI_BUFFEROVERFLOW S_FALSE -#define DI_PROPNOEFFECT S_FALSE -#define DI_NOEFFECT S_FALSE -#define DI_POLLEDDEVICE ((HRESULT)0x00000002L) -#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L) -#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L) -#define DI_TRUNCATED ((HRESULT)0x00000008L) -#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000BL) -#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL) -#define DI_WRITEPROTECT ((HRESULT)0x00000013L) - -#define DIERR_OLDDIRECTINPUTVERSION \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION) -#define DIERR_BETADIRECTINPUTVERSION \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP) -#define DIERR_BADDRIVERVER \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL) -#define DIERR_DEVICENOTREG REGDB_E_CLASSNOTREG -#define DIERR_NOTFOUND \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) -#define DIERR_OBJECTNOTFOUND \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) -#define DIERR_INVALIDPARAM E_INVALIDARG -#define DIERR_NOINTERFACE E_NOINTERFACE -#define DIERR_GENERIC E_FAIL -#define DIERR_OUTOFMEMORY E_OUTOFMEMORY -#define DIERR_UNSUPPORTED E_NOTIMPL -#define DIERR_NOTINITIALIZED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY) -#define DIERR_ALREADYINITIALIZED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED) -#define DIERR_NOAGGREGATION CLASS_E_NOAGGREGATION -#define DIERR_OTHERAPPHASPRIO E_ACCESSDENIED -#define DIERR_INPUTLOST \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT) -#define DIERR_ACQUIRED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY) -#define DIERR_NOTACQUIRED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS) -#define DIERR_READONLY E_ACCESSDENIED -#define DIERR_HANDLEEXISTS E_ACCESSDENIED -#ifndef E_PENDING -#define E_PENDING 0x8000000AL -#endif -#define DIERR_INSUFFICIENTPRIVS 0x80040200L -#define DIERR_DEVICEFULL 0x80040201L -#define DIERR_MOREDATA 0x80040202L -#define DIERR_NOTDOWNLOADED 0x80040203L -#define DIERR_HASEFFECTS 0x80040204L -#define DIERR_NOTEXCLUSIVEACQUIRED 0x80040205L -#define DIERR_INCOMPLETEEFFECT 0x80040206L -#define DIERR_NOTBUFFERED 0x80040207L -#define DIERR_EFFECTPLAYING 0x80040208L -#define DIERR_UNPLUGGED 0x80040209L -#define DIERR_REPORTFULL 0x8004020AL -#define DIERR_MAPFILEFAIL 0x8004020BL - -#define DIENUM_STOP 0 -#define DIENUM_CONTINUE 1 - -#define DIEDFL_ALLDEVICES 0x00000000 -#define DIEDFL_ATTACHEDONLY 0x00000001 -#define DIEDFL_FORCEFEEDBACK 0x00000100 -#define DIEDFL_INCLUDEALIASES 0x00010000 -#define DIEDFL_INCLUDEPHANTOMS 0x00020000 -#define DIEDFL_INCLUDEHIDDEN 0x00040000 - -#define DIDEVTYPE_DEVICE 1 -#define DIDEVTYPE_MOUSE 2 -#define DIDEVTYPE_KEYBOARD 3 -#define DIDEVTYPE_JOYSTICK 4 -#define DIDEVTYPE_HID 0x00010000 - -#define DI8DEVCLASS_ALL 0 -#define DI8DEVCLASS_DEVICE 1 -#define DI8DEVCLASS_POINTER 2 -#define DI8DEVCLASS_KEYBOARD 3 -#define DI8DEVCLASS_GAMECTRL 4 - -#define DI8DEVTYPE_DEVICE 0x11 -#define DI8DEVTYPE_MOUSE 0x12 -#define DI8DEVTYPE_KEYBOARD 0x13 -#define DI8DEVTYPE_JOYSTICK 0x14 -#define DI8DEVTYPE_GAMEPAD 0x15 -#define DI8DEVTYPE_DRIVING 0x16 -#define DI8DEVTYPE_FLIGHT 0x17 -#define DI8DEVTYPE_1STPERSON 0x18 -#define DI8DEVTYPE_DEVICECTRL 0x19 -#define DI8DEVTYPE_SCREENPOINTER 0x1A -#define DI8DEVTYPE_REMOTE 0x1B -#define DI8DEVTYPE_SUPPLEMENTAL 0x1C - -#define DIDEVTYPEMOUSE_UNKNOWN 1 -#define DIDEVTYPEMOUSE_TRADITIONAL 2 -#define DIDEVTYPEMOUSE_FINGERSTICK 3 -#define DIDEVTYPEMOUSE_TOUCHPAD 4 -#define DIDEVTYPEMOUSE_TRACKBALL 5 - -#define DIDEVTYPEKEYBOARD_UNKNOWN 0 -#define DIDEVTYPEKEYBOARD_PCXT 1 -#define DIDEVTYPEKEYBOARD_OLIVETTI 2 -#define DIDEVTYPEKEYBOARD_PCAT 3 -#define DIDEVTYPEKEYBOARD_PCENH 4 -#define DIDEVTYPEKEYBOARD_NOKIA1050 5 -#define DIDEVTYPEKEYBOARD_NOKIA9140 6 -#define DIDEVTYPEKEYBOARD_NEC98 7 -#define DIDEVTYPEKEYBOARD_NEC98LAPTOP 8 -#define DIDEVTYPEKEYBOARD_NEC98106 9 -#define DIDEVTYPEKEYBOARD_JAPAN106 10 -#define DIDEVTYPEKEYBOARD_JAPANAX 11 -#define DIDEVTYPEKEYBOARD_J3100 12 - -#define DIDEVTYPEJOYSTICK_UNKNOWN 1 -#define DIDEVTYPEJOYSTICK_TRADITIONAL 2 -#define DIDEVTYPEJOYSTICK_FLIGHTSTICK 3 -#define DIDEVTYPEJOYSTICK_GAMEPAD 4 -#define DIDEVTYPEJOYSTICK_RUDDER 5 -#define DIDEVTYPEJOYSTICK_WHEEL 6 -#define DIDEVTYPEJOYSTICK_HEADTRACKER 7 - -#define DI8DEVTYPEMOUSE_UNKNOWN 1 -#define DI8DEVTYPEMOUSE_TRADITIONAL 2 -#define DI8DEVTYPEMOUSE_FINGERSTICK 3 -#define DI8DEVTYPEMOUSE_TOUCHPAD 4 -#define DI8DEVTYPEMOUSE_TRACKBALL 5 -#define DI8DEVTYPEMOUSE_ABSOLUTE 6 - -#define DI8DEVTYPEKEYBOARD_UNKNOWN 0 -#define DI8DEVTYPEKEYBOARD_PCXT 1 -#define DI8DEVTYPEKEYBOARD_OLIVETTI 2 -#define DI8DEVTYPEKEYBOARD_PCAT 3 -#define DI8DEVTYPEKEYBOARD_PCENH 4 -#define DI8DEVTYPEKEYBOARD_NOKIA1050 5 -#define DI8DEVTYPEKEYBOARD_NOKIA9140 6 -#define DI8DEVTYPEKEYBOARD_NEC98 7 -#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP 8 -#define DI8DEVTYPEKEYBOARD_NEC98106 9 -#define DI8DEVTYPEKEYBOARD_JAPAN106 10 -#define DI8DEVTYPEKEYBOARD_JAPANAX 11 -#define DI8DEVTYPEKEYBOARD_J3100 12 - -#define DI8DEVTYPE_LIMITEDGAMESUBTYPE 1 - -#define DI8DEVTYPEJOYSTICK_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEJOYSTICK_STANDARD 2 - -#define DI8DEVTYPEGAMEPAD_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEGAMEPAD_STANDARD 2 -#define DI8DEVTYPEGAMEPAD_TILT 3 - -#define DI8DEVTYPEDRIVING_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEDRIVING_COMBINEDPEDALS 2 -#define DI8DEVTYPEDRIVING_DUALPEDALS 3 -#define DI8DEVTYPEDRIVING_THREEPEDALS 4 -#define DI8DEVTYPEDRIVING_HANDHELD 5 - -#define DI8DEVTYPEFLIGHT_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEFLIGHT_STICK 2 -#define DI8DEVTYPEFLIGHT_YOKE 3 -#define DI8DEVTYPEFLIGHT_RC 4 - -#define DI8DEVTYPE1STPERSON_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPE1STPERSON_UNKNOWN 2 -#define DI8DEVTYPE1STPERSON_SIXDOF 3 -#define DI8DEVTYPE1STPERSON_SHOOTER 4 - -#define DI8DEVTYPESCREENPTR_UNKNOWN 2 -#define DI8DEVTYPESCREENPTR_LIGHTGUN 3 -#define DI8DEVTYPESCREENPTR_LIGHTPEN 4 -#define DI8DEVTYPESCREENPTR_TOUCH 5 - -#define DI8DEVTYPEREMOTE_UNKNOWN 2 - -#define DI8DEVTYPEDEVICECTRL_UNKNOWN 2 -#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION 3 -#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4 - -#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN 2 -#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER 3 -#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER 4 -#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER 5 -#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE 6 -#define DI8DEVTYPESUPPLEMENTAL_SHIFTER 7 -#define DI8DEVTYPESUPPLEMENTAL_THROTTLE 8 -#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE 9 -#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS 10 -#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11 -#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12 -#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13 - -#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType) -#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType) - -typedef struct DIDEVICEOBJECTINSTANCE_DX3A { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - CHAR tszName[MAX_PATH]; -} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A; -typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A; -typedef struct DIDEVICEOBJECTINSTANCE_DX3W { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - WCHAR tszName[MAX_PATH]; -} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W; -typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W; - -DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE_DX3) -DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE_DX3) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE_DX3) - -typedef struct DIDEVICEOBJECTINSTANCEA { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - CHAR tszName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; - WORD wCollectionNumber; - WORD wDesignatorIndex; - WORD wUsagePage; - WORD wUsage; - DWORD dwDimension; - WORD wExponent; - WORD wReserved; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA; -typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA; - -typedef struct DIDEVICEOBJECTINSTANCEW { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - WCHAR tszName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; - WORD wCollectionNumber; - WORD wDesignatorIndex; - WORD wUsagePage; - WORD wUsage; - DWORD dwDimension; - WORD wExponent; - WORD wReserved; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW; -typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW; - -DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE) -DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE) - -typedef struct DIDEVICEINSTANCE_DX3A { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - CHAR tszInstanceName[MAX_PATH]; - CHAR tszProductName[MAX_PATH]; -} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A; -typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A; -typedef struct DIDEVICEINSTANCE_DX3W { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - WCHAR tszInstanceName[MAX_PATH]; - WCHAR tszProductName[MAX_PATH]; -} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W; -typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W; - -DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE_DX3) -DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE_DX3) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE_DX3) - -typedef struct DIDEVICEINSTANCEA { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - CHAR tszInstanceName[MAX_PATH]; - CHAR tszProductName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - GUID guidFFDriver; - WORD wUsagePage; - WORD wUsage; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA; -typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA; - -typedef struct DIDEVICEINSTANCEW { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - WCHAR tszInstanceName[MAX_PATH]; - WCHAR tszProductName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - GUID guidFFDriver; - WORD wUsagePage; - WORD wUsage; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW; -typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW; - -DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE) -DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE) - -typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA,LPVOID); -typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW,LPVOID); -DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESCALLBACK) - -#define DIEDBS_MAPPEDPRI1 0x00000001 -#define DIEDBS_MAPPEDPRI2 0x00000002 -#define DIEDBS_RECENTDEVICE 0x00000010 -#define DIEDBS_NEWDEVICE 0x00000020 - -#define DIEDBSFL_ATTACHEDONLY 0x00000000 -#define DIEDBSFL_THISUSER 0x00000010 -#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK -#define DIEDBSFL_AVAILABLEDEVICES 0x00001000 -#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000 -#define DIEDBSFL_NONGAMINGDEVICES 0x00004000 -#define DIEDBSFL_VALID 0x00007110 - -#if DIRECTINPUT_VERSION >= 0x0800 -typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA,LPDIRECTINPUTDEVICE8A,DWORD,DWORD,LPVOID); -typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW,LPDIRECTINPUTDEVICE8W,DWORD,DWORD,LPVOID); -DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESBYSEMANTICSCB) -#endif - -typedef BOOL (CALLBACK *LPDICONFIGUREDEVICESCALLBACK)(LPUNKNOWN,LPVOID); - -typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA,LPVOID); -typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW,LPVOID); -DECL_WINELIB_TYPE_AW(LPDIENUMDEVICEOBJECTSCALLBACK) - -#if DIRECTINPUT_VERSION >= 0x0500 -typedef BOOL (CALLBACK *LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID); -#endif - -#define DIK_ESCAPE 0x01 -#define DIK_1 0x02 -#define DIK_2 0x03 -#define DIK_3 0x04 -#define DIK_4 0x05 -#define DIK_5 0x06 -#define DIK_6 0x07 -#define DIK_7 0x08 -#define DIK_8 0x09 -#define DIK_9 0x0A -#define DIK_0 0x0B -#define DIK_MINUS 0x0C /* - on main keyboard */ -#define DIK_EQUALS 0x0D -#define DIK_BACK 0x0E /* backspace */ -#define DIK_TAB 0x0F -#define DIK_Q 0x10 -#define DIK_W 0x11 -#define DIK_E 0x12 -#define DIK_R 0x13 -#define DIK_T 0x14 -#define DIK_Y 0x15 -#define DIK_U 0x16 -#define DIK_I 0x17 -#define DIK_O 0x18 -#define DIK_P 0x19 -#define DIK_LBRACKET 0x1A -#define DIK_RBRACKET 0x1B -#define DIK_RETURN 0x1C /* Enter on main keyboard */ -#define DIK_LCONTROL 0x1D -#define DIK_A 0x1E -#define DIK_S 0x1F -#define DIK_D 0x20 -#define DIK_F 0x21 -#define DIK_G 0x22 -#define DIK_H 0x23 -#define DIK_J 0x24 -#define DIK_K 0x25 -#define DIK_L 0x26 -#define DIK_SEMICOLON 0x27 -#define DIK_APOSTROPHE 0x28 -#define DIK_GRAVE 0x29 /* accent grave */ -#define DIK_LSHIFT 0x2A -#define DIK_BACKSLASH 0x2B -#define DIK_Z 0x2C -#define DIK_X 0x2D -#define DIK_C 0x2E -#define DIK_V 0x2F -#define DIK_B 0x30 -#define DIK_N 0x31 -#define DIK_M 0x32 -#define DIK_COMMA 0x33 -#define DIK_PERIOD 0x34 /* . on main keyboard */ -#define DIK_SLASH 0x35 /* / on main keyboard */ -#define DIK_RSHIFT 0x36 -#define DIK_MULTIPLY 0x37 /* * on numeric keypad */ -#define DIK_LMENU 0x38 /* left Alt */ -#define DIK_SPACE 0x39 -#define DIK_CAPITAL 0x3A -#define DIK_F1 0x3B -#define DIK_F2 0x3C -#define DIK_F3 0x3D -#define DIK_F4 0x3E -#define DIK_F5 0x3F -#define DIK_F6 0x40 -#define DIK_F7 0x41 -#define DIK_F8 0x42 -#define DIK_F9 0x43 -#define DIK_F10 0x44 -#define DIK_NUMLOCK 0x45 -#define DIK_SCROLL 0x46 /* Scroll Lock */ -#define DIK_NUMPAD7 0x47 -#define DIK_NUMPAD8 0x48 -#define DIK_NUMPAD9 0x49 -#define DIK_SUBTRACT 0x4A /* - on numeric keypad */ -#define DIK_NUMPAD4 0x4B -#define DIK_NUMPAD5 0x4C -#define DIK_NUMPAD6 0x4D -#define DIK_ADD 0x4E /* + on numeric keypad */ -#define DIK_NUMPAD1 0x4F -#define DIK_NUMPAD2 0x50 -#define DIK_NUMPAD3 0x51 -#define DIK_NUMPAD0 0x52 -#define DIK_DECIMAL 0x53 /* . on numeric keypad */ -#define DIK_OEM_102 0x56 /* < > | on UK/Germany keyboards */ -#define DIK_F11 0x57 -#define DIK_F12 0x58 -#define DIK_F13 0x64 /* (NEC PC98) */ -#define DIK_F14 0x65 /* (NEC PC98) */ -#define DIK_F15 0x66 /* (NEC PC98) */ -#define DIK_KANA 0x70 /* (Japanese keyboard) */ -#define DIK_ABNT_C1 0x73 /* / ? on Portugese (Brazilian) keyboards */ -#define DIK_CONVERT 0x79 /* (Japanese keyboard) */ -#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */ -#define DIK_YEN 0x7D /* (Japanese keyboard) */ -#define DIK_ABNT_C2 0x7E /* Numpad . on Portugese (Brazilian) keyboards */ -#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */ -#define DIK_CIRCUMFLEX 0x90 /* (Japanese keyboard) */ -#define DIK_AT 0x91 /* (NEC PC98) */ -#define DIK_COLON 0x92 /* (NEC PC98) */ -#define DIK_UNDERLINE 0x93 /* (NEC PC98) */ -#define DIK_KANJI 0x94 /* (Japanese keyboard) */ -#define DIK_STOP 0x95 /* (NEC PC98) */ -#define DIK_AX 0x96 /* (Japan AX) */ -#define DIK_UNLABELED 0x97 /* (J3100) */ -#define DIK_NEXTTRACK 0x99 /* Next Track */ -#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */ -#define DIK_RCONTROL 0x9D -#define DIK_MUTE 0xA0 /* Mute */ -#define DIK_CALCULATOR 0xA1 /* Calculator */ -#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */ -#define DIK_MEDIASTOP 0xA4 /* Media Stop */ -#define DIK_VOLUMEDOWN 0xAE /* Volume - */ -#define DIK_VOLUMEUP 0xB0 /* Volume + */ -#define DIK_WEBHOME 0xB2 /* Web home */ -#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */ -#define DIK_DIVIDE 0xB5 /* / on numeric keypad */ -#define DIK_SYSRQ 0xB7 -#define DIK_RMENU 0xB8 /* right Alt */ -#define DIK_PAUSE 0xC5 /* Pause */ -#define DIK_HOME 0xC7 /* Home on arrow keypad */ -#define DIK_UP 0xC8 /* UpArrow on arrow keypad */ -#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */ -#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */ -#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */ -#define DIK_END 0xCF /* End on arrow keypad */ -#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */ -#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */ -#define DIK_INSERT 0xD2 /* Insert on arrow keypad */ -#define DIK_DELETE 0xD3 /* Delete on arrow keypad */ -#define DIK_LWIN 0xDB /* Left Windows key */ -#define DIK_RWIN 0xDC /* Right Windows key */ -#define DIK_APPS 0xDD /* AppMenu key */ -#define DIK_POWER 0xDE -#define DIK_SLEEP 0xDF -#define DIK_WAKE 0xE3 /* System Wake */ -#define DIK_WEBSEARCH 0xE5 /* Web Search */ -#define DIK_WEBFAVORITES 0xE6 /* Web Favorites */ -#define DIK_WEBREFRESH 0xE7 /* Web Refresh */ -#define DIK_WEBSTOP 0xE8 /* Web Stop */ -#define DIK_WEBFORWARD 0xE9 /* Web Forward */ -#define DIK_WEBBACK 0xEA /* Web Back */ -#define DIK_MYCOMPUTER 0xEB /* My Computer */ -#define DIK_MAIL 0xEC /* Mail */ -#define DIK_MEDIASELECT 0xED /* Media Select */ - -#define DIK_BACKSPACE DIK_BACK /* backspace */ -#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */ -#define DIK_LALT DIK_LMENU /* left Alt */ -#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */ -#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */ -#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */ -#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */ -#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */ -#define DIK_RALT DIK_RMENU /* right Alt */ -#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */ -#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */ -#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */ -#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */ -#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */ -#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */ - -#define DIDFT_ALL 0x00000000 -#define DIDFT_RELAXIS 0x00000001 -#define DIDFT_ABSAXIS 0x00000002 -#define DIDFT_AXIS 0x00000003 -#define DIDFT_PSHBUTTON 0x00000004 -#define DIDFT_TGLBUTTON 0x00000008 -#define DIDFT_BUTTON 0x0000000C -#define DIDFT_POV 0x00000010 -#define DIDFT_COLLECTION 0x00000040 -#define DIDFT_NODATA 0x00000080 -#define DIDFT_ANYINSTANCE 0x00FFFF00 -#define DIDFT_INSTANCEMASK DIDFT_ANYINSTANCE -#define DIDFT_MAKEINSTANCE(n) ((WORD)(n) << 8) -#define DIDFT_GETTYPE(n) LOBYTE(n) -#define DIDFT_GETINSTANCE(n) LOWORD((n) >> 8) -#define DIDFT_FFACTUATOR 0x01000000 -#define DIDFT_FFEFFECTTRIGGER 0x02000000 -#if DIRECTINPUT_VERSION >= 0x050a -#define DIDFT_OUTPUT 0x10000000 -#define DIDFT_VENDORDEFINED 0x04000000 -#define DIDFT_ALIAS 0x08000000 -#endif /* DI5a */ -#ifndef DIDFT_OPTIONAL -#define DIDFT_OPTIONAL 0x80000000 -#endif -#define DIDFT_ENUMCOLLECTION(n) ((WORD)(n) << 8) -#define DIDFT_NOCOLLECTION 0x00FFFF00 - -#define DIDF_ABSAXIS 0x00000001 -#define DIDF_RELAXIS 0x00000002 - -#define DIGDD_PEEK 0x00000001 - -#define DISEQUENCE_COMPARE(dwSq1,cmp,dwSq2) ((int)((dwSq1) - (dwSq2)) cmp 0) - -typedef struct DIDEVICEOBJECTDATA_DX3 { - DWORD dwOfs; - DWORD dwData; - DWORD dwTimeStamp; - DWORD dwSequence; -} DIDEVICEOBJECTDATA_DX3,*LPDIDEVICEOBJECTDATA_DX3; -typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX3; - -typedef struct DIDEVICEOBJECTDATA { - DWORD dwOfs; - DWORD dwData; - DWORD dwTimeStamp; - DWORD dwSequence; -#if(DIRECTINPUT_VERSION >= 0x0800) - UINT_PTR uAppData; -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ -} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA; -typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA; - -typedef struct _DIOBJECTDATAFORMAT { - const GUID *pguid; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; -} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT; -typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT; - -typedef struct _DIDATAFORMAT { - DWORD dwSize; - DWORD dwObjSize; - DWORD dwFlags; - DWORD dwDataSize; - DWORD dwNumObjs; - LPDIOBJECTDATAFORMAT rgodf; -} DIDATAFORMAT, *LPDIDATAFORMAT; -typedef const DIDATAFORMAT *LPCDIDATAFORMAT; - -#if DIRECTINPUT_VERSION >= 0x0500 -#define DIDOI_FFACTUATOR 0x00000001 -#define DIDOI_FFEFFECTTRIGGER 0x00000002 -#define DIDOI_POLLED 0x00008000 -#define DIDOI_ASPECTPOSITION 0x00000100 -#define DIDOI_ASPECTVELOCITY 0x00000200 -#define DIDOI_ASPECTACCEL 0x00000300 -#define DIDOI_ASPECTFORCE 0x00000400 -#define DIDOI_ASPECTMASK 0x00000F00 -#endif /* DI5 */ -#if DIRECTINPUT_VERSION >= 0x050a -#define DIDOI_GUIDISUSAGE 0x00010000 -#endif /* DI5a */ - -typedef struct DIPROPHEADER { - DWORD dwSize; - DWORD dwHeaderSize; - DWORD dwObj; - DWORD dwHow; -} DIPROPHEADER,*LPDIPROPHEADER; -typedef const DIPROPHEADER *LPCDIPROPHEADER; - -#define DIPH_DEVICE 0 -#define DIPH_BYOFFSET 1 -#define DIPH_BYID 2 -#if DIRECTINPUT_VERSION >= 0x050a -#define DIPH_BYUSAGE 3 - -#define DIMAKEUSAGEDWORD(UsagePage, Usage) (DWORD)MAKELONG(Usage, UsagePage) -#endif /* DI5a */ - -typedef struct DIPROPDWORD { - DIPROPHEADER diph; - DWORD dwData; -} DIPROPDWORD, *LPDIPROPDWORD; -typedef const DIPROPDWORD *LPCDIPROPDWORD; - -typedef struct DIPROPRANGE { - DIPROPHEADER diph; - LONG lMin; - LONG lMax; -} DIPROPRANGE, *LPDIPROPRANGE; -typedef const DIPROPRANGE *LPCDIPROPRANGE; - -#define DIPROPRANGE_NOMIN ((LONG)0x80000000) -#define DIPROPRANGE_NOMAX ((LONG)0x7FFFFFFF) - -#if DIRECTINPUT_VERSION >= 0x050a -typedef struct DIPROPCAL { - DIPROPHEADER diph; - LONG lMin; - LONG lCenter; - LONG lMax; -} DIPROPCAL, *LPDIPROPCAL; -typedef const DIPROPCAL *LPCDIPROPCAL; - -typedef struct DIPROPCALPOV { - DIPROPHEADER diph; - LONG lMin[5]; - LONG lMax[5]; -} DIPROPCALPOV, *LPDIPROPCALPOV; -typedef const DIPROPCALPOV *LPCDIPROPCALPOV; - -typedef struct DIPROPGUIDANDPATH { - DIPROPHEADER diph; - GUID guidClass; - WCHAR wszPath[MAX_PATH]; -} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH; -typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH; - -typedef struct DIPROPSTRING { - DIPROPHEADER diph; - WCHAR wsz[MAX_PATH]; -} DIPROPSTRING, *LPDIPROPSTRING; -typedef const DIPROPSTRING *LPCDIPROPSTRING; -#endif /* DI5a */ - -#if DIRECTINPUT_VERSION >= 0x0800 -typedef struct DIPROPPOINTER { - DIPROPHEADER diph; - UINT_PTR uData; -} DIPROPPOINTER, *LPDIPROPPOINTER; -typedef const DIPROPPOINTER *LPCDIPROPPOINTER; -#endif /* DI8 */ - -/* special property GUIDs */ -#ifdef __cplusplus -#define MAKEDIPROP(prop) (*(const GUID *)(prop)) -#else -#define MAKEDIPROP(prop) ((REFGUID)(prop)) -#endif -#define DIPROP_BUFFERSIZE MAKEDIPROP(1) -#define DIPROP_AXISMODE MAKEDIPROP(2) - -#define DIPROPAXISMODE_ABS 0 -#define DIPROPAXISMODE_REL 1 - -#define DIPROP_GRANULARITY MAKEDIPROP(3) -#define DIPROP_RANGE MAKEDIPROP(4) -#define DIPROP_DEADZONE MAKEDIPROP(5) -#define DIPROP_SATURATION MAKEDIPROP(6) -#define DIPROP_FFGAIN MAKEDIPROP(7) -#define DIPROP_FFLOAD MAKEDIPROP(8) -#define DIPROP_AUTOCENTER MAKEDIPROP(9) - -#define DIPROPAUTOCENTER_OFF 0 -#define DIPROPAUTOCENTER_ON 1 - -#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10) - -#define DIPROPCALIBRATIONMODE_COOKED 0 -#define DIPROPCALIBRATIONMODE_RAW 1 - -#if DIRECTINPUT_VERSION >= 0x050a -#define DIPROP_CALIBRATION MAKEDIPROP(11) -#define DIPROP_GUIDANDPATH MAKEDIPROP(12) -#define DIPROP_INSTANCENAME MAKEDIPROP(13) -#define DIPROP_PRODUCTNAME MAKEDIPROP(14) -#endif - -#if DIRECTINPUT_VERSION >= 0x5B2 -#define DIPROP_JOYSTICKID MAKEDIPROP(15) -#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16) -#endif - -#if DIRECTINPUT_VERSION >= 0x0700 -#define DIPROP_PHYSICALRANGE MAKEDIPROP(18) -#define DIPROP_LOGICALRANGE MAKEDIPROP(19) -#endif - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIPROP_KEYNAME MAKEDIPROP(20) -#define DIPROP_CPOINTS MAKEDIPROP(21) -#define DIPROP_APPDATA MAKEDIPROP(22) -#define DIPROP_SCANCODE MAKEDIPROP(23) -#define DIPROP_VIDPID MAKEDIPROP(24) -#define DIPROP_USERNAME MAKEDIPROP(25) -#define DIPROP_TYPENAME MAKEDIPROP(26) - -#define MAXCPOINTSNUM 8 - -typedef struct _CPOINT { - LONG lP; - DWORD dwLog; -} CPOINT, *PCPOINT; - -typedef struct DIPROPCPOINTS { - DIPROPHEADER diph; - DWORD dwCPointsNum; - CPOINT cp[MAXCPOINTSNUM]; -} DIPROPCPOINTS, *LPDIPROPCPOINTS; -typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS; -#endif /* DI8 */ - - -typedef struct DIDEVCAPS_DX3 { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDevType; - DWORD dwAxes; - DWORD dwButtons; - DWORD dwPOVs; -} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3; - -typedef struct DIDEVCAPS { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDevType; - DWORD dwAxes; - DWORD dwButtons; - DWORD dwPOVs; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFSamplePeriod; - DWORD dwFFMinTimeResolution; - DWORD dwFirmwareRevision; - DWORD dwHardwareRevision; - DWORD dwFFDriverVersion; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVCAPS,*LPDIDEVCAPS; - -#define DIDC_ATTACHED 0x00000001 -#define DIDC_POLLEDDEVICE 0x00000002 -#define DIDC_EMULATED 0x00000004 -#define DIDC_POLLEDDATAFORMAT 0x00000008 -#define DIDC_FORCEFEEDBACK 0x00000100 -#define DIDC_FFATTACK 0x00000200 -#define DIDC_FFFADE 0x00000400 -#define DIDC_SATURATION 0x00000800 -#define DIDC_POSNEGCOEFFICIENTS 0x00001000 -#define DIDC_POSNEGSATURATION 0x00002000 -#define DIDC_DEADBAND 0x00004000 -#define DIDC_STARTDELAY 0x00008000 -#define DIDC_ALIAS 0x00010000 -#define DIDC_PHANTOM 0x00020000 -#define DIDC_HIDDEN 0x00040000 - - -/* SetCooperativeLevel dwFlags */ -#define DISCL_EXCLUSIVE 0x00000001 -#define DISCL_NONEXCLUSIVE 0x00000002 -#define DISCL_FOREGROUND 0x00000004 -#define DISCL_BACKGROUND 0x00000008 -#define DISCL_NOWINKEY 0x00000010 - -#if (DIRECTINPUT_VERSION >= 0x0500) -/* Device FF flags */ -#define DISFFC_RESET 0x00000001 -#define DISFFC_STOPALL 0x00000002 -#define DISFFC_PAUSE 0x00000004 -#define DISFFC_CONTINUE 0x00000008 -#define DISFFC_SETACTUATORSON 0x00000010 -#define DISFFC_SETACTUATORSOFF 0x00000020 - -#define DIGFFS_EMPTY 0x00000001 -#define DIGFFS_STOPPED 0x00000002 -#define DIGFFS_PAUSED 0x00000004 -#define DIGFFS_ACTUATORSON 0x00000010 -#define DIGFFS_ACTUATORSOFF 0x00000020 -#define DIGFFS_POWERON 0x00000040 -#define DIGFFS_POWEROFF 0x00000080 -#define DIGFFS_SAFETYSWITCHON 0x00000100 -#define DIGFFS_SAFETYSWITCHOFF 0x00000200 -#define DIGFFS_USERFFSWITCHON 0x00000400 -#define DIGFFS_USERFFSWITCHOFF 0x00000800 -#define DIGFFS_DEVICELOST 0x80000000 - -/* Effect flags */ -#define DIEFT_ALL 0x00000000 - -#define DIEFT_CONSTANTFORCE 0x00000001 -#define DIEFT_RAMPFORCE 0x00000002 -#define DIEFT_PERIODIC 0x00000003 -#define DIEFT_CONDITION 0x00000004 -#define DIEFT_CUSTOMFORCE 0x00000005 -#define DIEFT_HARDWARE 0x000000FF -#define DIEFT_FFATTACK 0x00000200 -#define DIEFT_FFFADE 0x00000400 -#define DIEFT_SATURATION 0x00000800 -#define DIEFT_POSNEGCOEFFICIENTS 0x00001000 -#define DIEFT_POSNEGSATURATION 0x00002000 -#define DIEFT_DEADBAND 0x00004000 -#define DIEFT_STARTDELAY 0x00008000 -#define DIEFT_GETTYPE(n) LOBYTE(n) - -#define DIEFF_OBJECTIDS 0x00000001 -#define DIEFF_OBJECTOFFSETS 0x00000002 -#define DIEFF_CARTESIAN 0x00000010 -#define DIEFF_POLAR 0x00000020 -#define DIEFF_SPHERICAL 0x00000040 - -#define DIEP_DURATION 0x00000001 -#define DIEP_SAMPLEPERIOD 0x00000002 -#define DIEP_GAIN 0x00000004 -#define DIEP_TRIGGERBUTTON 0x00000008 -#define DIEP_TRIGGERREPEATINTERVAL 0x00000010 -#define DIEP_AXES 0x00000020 -#define DIEP_DIRECTION 0x00000040 -#define DIEP_ENVELOPE 0x00000080 -#define DIEP_TYPESPECIFICPARAMS 0x00000100 -#if(DIRECTINPUT_VERSION >= 0x0600) -#define DIEP_STARTDELAY 0x00000200 -#define DIEP_ALLPARAMS_DX5 0x000001FF -#define DIEP_ALLPARAMS 0x000003FF -#else -#define DIEP_ALLPARAMS 0x000001FF -#endif /* DIRECTINPUT_VERSION >= 0x0600 */ -#define DIEP_START 0x20000000 -#define DIEP_NORESTART 0x40000000 -#define DIEP_NODOWNLOAD 0x80000000 -#define DIEB_NOTRIGGER 0xFFFFFFFF - -#define DIES_SOLO 0x00000001 -#define DIES_NODOWNLOAD 0x80000000 - -#define DIEGES_PLAYING 0x00000001 -#define DIEGES_EMULATED 0x00000002 - -#define DI_DEGREES 100 -#define DI_FFNOMINALMAX 10000 -#define DI_SECONDS 1000000 - -typedef struct DICONSTANTFORCE { - LONG lMagnitude; -} DICONSTANTFORCE, *LPDICONSTANTFORCE; -typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE; - -typedef struct DIRAMPFORCE { - LONG lStart; - LONG lEnd; -} DIRAMPFORCE, *LPDIRAMPFORCE; -typedef const DIRAMPFORCE *LPCDIRAMPFORCE; - -typedef struct DIPERIODIC { - DWORD dwMagnitude; - LONG lOffset; - DWORD dwPhase; - DWORD dwPeriod; -} DIPERIODIC, *LPDIPERIODIC; -typedef const DIPERIODIC *LPCDIPERIODIC; - -typedef struct DICONDITION { - LONG lOffset; - LONG lPositiveCoefficient; - LONG lNegativeCoefficient; - DWORD dwPositiveSaturation; - DWORD dwNegativeSaturation; - LONG lDeadBand; -} DICONDITION, *LPDICONDITION; -typedef const DICONDITION *LPCDICONDITION; - -typedef struct DICUSTOMFORCE { - DWORD cChannels; - DWORD dwSamplePeriod; - DWORD cSamples; - LPLONG rglForceData; -} DICUSTOMFORCE, *LPDICUSTOMFORCE; -typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE; - -typedef struct DIENVELOPE { - DWORD dwSize; - DWORD dwAttackLevel; - DWORD dwAttackTime; - DWORD dwFadeLevel; - DWORD dwFadeTime; -} DIENVELOPE, *LPDIENVELOPE; -typedef const DIENVELOPE *LPCDIENVELOPE; - -typedef struct DIEFFECT_DX5 { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDuration; - DWORD dwSamplePeriod; - DWORD dwGain; - DWORD dwTriggerButton; - DWORD dwTriggerRepeatInterval; - DWORD cAxes; - LPDWORD rgdwAxes; - LPLONG rglDirection; - LPDIENVELOPE lpEnvelope; - DWORD cbTypeSpecificParams; - LPVOID lpvTypeSpecificParams; -} DIEFFECT_DX5, *LPDIEFFECT_DX5; -typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5; - -typedef struct DIEFFECT { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDuration; - DWORD dwSamplePeriod; - DWORD dwGain; - DWORD dwTriggerButton; - DWORD dwTriggerRepeatInterval; - DWORD cAxes; - LPDWORD rgdwAxes; - LPLONG rglDirection; - LPDIENVELOPE lpEnvelope; - DWORD cbTypeSpecificParams; - LPVOID lpvTypeSpecificParams; -#if(DIRECTINPUT_VERSION >= 0x0600) - DWORD dwStartDelay; -#endif /* DIRECTINPUT_VERSION >= 0x0600 */ -} DIEFFECT, *LPDIEFFECT; -typedef const DIEFFECT *LPCDIEFFECT; -typedef DIEFFECT DIEFFECT_DX6; -typedef LPDIEFFECT LPDIEFFECT_DX6; - -typedef struct DIEFFECTINFOA { - DWORD dwSize; - GUID guid; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - CHAR tszName[MAX_PATH]; -} DIEFFECTINFOA, *LPDIEFFECTINFOA; -typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA; - -typedef struct DIEFFECTINFOW { - DWORD dwSize; - GUID guid; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - WCHAR tszName[MAX_PATH]; -} DIEFFECTINFOW, *LPDIEFFECTINFOW; -typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW; - -DECL_WINELIB_TYPE_AW(DIEFFECTINFO) -DECL_WINELIB_TYPE_AW(LPDIEFFECTINFO) -DECL_WINELIB_TYPE_AW(LPCDIEFFECTINFO) - -typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID); -typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID); - -typedef struct DIEFFESCAPE { - DWORD dwSize; - DWORD dwCommand; - LPVOID lpvInBuffer; - DWORD cbInBuffer; - LPVOID lpvOutBuffer; - DWORD cbOutBuffer; -} DIEFFESCAPE, *LPDIEFFESCAPE; - -typedef struct DIJOYSTATE { - LONG lX; - LONG lY; - LONG lZ; - LONG lRx; - LONG lRy; - LONG lRz; - LONG rglSlider[2]; - DWORD rgdwPOV[4]; - BYTE rgbButtons[32]; -} DIJOYSTATE, *LPDIJOYSTATE; - -typedef struct DIJOYSTATE2 { - LONG lX; - LONG lY; - LONG lZ; - LONG lRx; - LONG lRy; - LONG lRz; - LONG rglSlider[2]; - DWORD rgdwPOV[4]; - BYTE rgbButtons[128]; - LONG lVX; /* 'v' as in velocity */ - LONG lVY; - LONG lVZ; - LONG lVRx; - LONG lVRy; - LONG lVRz; - LONG rglVSlider[2]; - LONG lAX; /* 'a' as in acceleration */ - LONG lAY; - LONG lAZ; - LONG lARx; - LONG lARy; - LONG lARz; - LONG rglASlider[2]; - LONG lFX; /* 'f' as in force */ - LONG lFY; - LONG lFZ; - LONG lFRx; /* 'fr' as in rotational force aka torque */ - LONG lFRy; - LONG lFRz; - LONG rglFSlider[2]; -} DIJOYSTATE2, *LPDIJOYSTATE2; - -#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX) -#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY) -#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ) -#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx) -#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy) -#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz) -#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \ - (n) * sizeof(LONG)) -#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \ - (n) * sizeof(DWORD)) -#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n)) -#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0) -#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1) -#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2) -#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3) -#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4) -#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5) -#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6) -#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7) -#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8) -#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9) -#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10) -#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11) -#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12) -#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13) -#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14) -#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15) -#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16) -#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17) -#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18) -#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19) -#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20) -#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21) -#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22) -#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23) -#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24) -#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25) -#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26) -#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27) -#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28) -#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29) -#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30) -#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31) -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -/* DInput 7 structures, types */ -#if(DIRECTINPUT_VERSION >= 0x0700) -typedef struct DIFILEEFFECT { - DWORD dwSize; - GUID GuidEffect; - LPCDIEFFECT lpDiEffect; - CHAR szFriendlyName[MAX_PATH]; -} DIFILEEFFECT, *LPDIFILEEFFECT; - -typedef const DIFILEEFFECT *LPCDIFILEEFFECT; -typedef BOOL (CALLBACK *LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID); -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -/* DInput 8 structures and types */ -#if DIRECTINPUT_VERSION >= 0x0800 -typedef struct _DIACTIONA { - UINT_PTR uAppData; - DWORD dwSemantic; - DWORD dwFlags; - __GNU_EXTENSION union { - LPCSTR lptszActionName; - UINT uResIdString; - } DUMMYUNIONNAME; - GUID guidInstance; - DWORD dwObjID; - DWORD dwHow; -} DIACTIONA, *LPDIACTIONA; -typedef const DIACTIONA *LPCDIACTIONA; - -typedef struct _DIACTIONW { - UINT_PTR uAppData; - DWORD dwSemantic; - DWORD dwFlags; - __GNU_EXTENSION union { - LPCWSTR lptszActionName; - UINT uResIdString; - } DUMMYUNIONNAME; - GUID guidInstance; - DWORD dwObjID; - DWORD dwHow; -} DIACTIONW, *LPDIACTIONW; -typedef const DIACTIONW *LPCDIACTIONW; - -DECL_WINELIB_TYPE_AW(DIACTION) -DECL_WINELIB_TYPE_AW(LPDIACTION) -DECL_WINELIB_TYPE_AW(LPCDIACTION) - -#define DIA_FORCEFEEDBACK 0x00000001 -#define DIA_APPMAPPED 0x00000002 -#define DIA_APPNOMAP 0x00000004 -#define DIA_NORANGE 0x00000008 -#define DIA_APPFIXED 0x00000010 - -#define DIAH_UNMAPPED 0x00000000 -#define DIAH_USERCONFIG 0x00000001 -#define DIAH_APPREQUESTED 0x00000002 -#define DIAH_HWAPP 0x00000004 -#define DIAH_HWDEFAULT 0x00000008 -#define DIAH_DEFAULT 0x00000020 -#define DIAH_ERROR 0x80000000 - -typedef struct _DIACTIONFORMATA { - DWORD dwSize; - DWORD dwActionSize; - DWORD dwDataSize; - DWORD dwNumActions; - LPDIACTIONA rgoAction; - GUID guidActionMap; - DWORD dwGenre; - DWORD dwBufferSize; - LONG lAxisMin; - LONG lAxisMax; - HINSTANCE hInstString; - FILETIME ftTimeStamp; - DWORD dwCRC; - CHAR tszActionMap[MAX_PATH]; -} DIACTIONFORMATA, *LPDIACTIONFORMATA; -typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA; - -typedef struct _DIACTIONFORMATW { - DWORD dwSize; - DWORD dwActionSize; - DWORD dwDataSize; - DWORD dwNumActions; - LPDIACTIONW rgoAction; - GUID guidActionMap; - DWORD dwGenre; - DWORD dwBufferSize; - LONG lAxisMin; - LONG lAxisMax; - HINSTANCE hInstString; - FILETIME ftTimeStamp; - DWORD dwCRC; - WCHAR tszActionMap[MAX_PATH]; -} DIACTIONFORMATW, *LPDIACTIONFORMATW; -typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW; - -DECL_WINELIB_TYPE_AW(DIACTIONFORMAT) -DECL_WINELIB_TYPE_AW(LPDIACTIONFORMAT) -DECL_WINELIB_TYPE_AW(LPCDIACTIONFORMAT) - -#define DIAFTS_NEWDEVICELOW 0xFFFFFFFF -#define DIAFTS_NEWDEVICEHIGH 0xFFFFFFFF -#define DIAFTS_UNUSEDDEVICELOW 0x00000000 -#define DIAFTS_UNUSEDDEVICEHIGH 0x00000000 - -#define DIDBAM_DEFAULT 0x00000000 -#define DIDBAM_PRESERVE 0x00000001 -#define DIDBAM_INITIALIZE 0x00000002 -#define DIDBAM_HWDEFAULTS 0x00000004 - -#define DIDSAM_DEFAULT 0x00000000 -#define DIDSAM_NOUSER 0x00000001 -#define DIDSAM_FORCESAVE 0x00000002 - -#define DICD_DEFAULT 0x00000000 -#define DICD_EDIT 0x00000001 - -#ifndef D3DCOLOR_DEFINED -typedef DWORD D3DCOLOR; -#define D3DCOLOR_DEFINED -#endif - -typedef struct _DICOLORSET { - DWORD dwSize; - D3DCOLOR cTextFore; - D3DCOLOR cTextHighlight; - D3DCOLOR cCalloutLine; - D3DCOLOR cCalloutHighlight; - D3DCOLOR cBorder; - D3DCOLOR cControlFill; - D3DCOLOR cHighlightFill; - D3DCOLOR cAreaFill; -} DICOLORSET, *LPDICOLORSET; -typedef const DICOLORSET *LPCDICOLORSET; - -typedef struct _DICONFIGUREDEVICESPARAMSA { - DWORD dwSize; - DWORD dwcUsers; - LPSTR lptszUserNames; - DWORD dwcFormats; - LPDIACTIONFORMATA lprgFormats; - HWND hwnd; - DICOLORSET dics; - LPUNKNOWN lpUnkDDSTarget; -} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA; -typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA; - -typedef struct _DICONFIGUREDEVICESPARAMSW { - DWORD dwSize; - DWORD dwcUsers; - LPWSTR lptszUserNames; - DWORD dwcFormats; - LPDIACTIONFORMATW lprgFormats; - HWND hwnd; - DICOLORSET dics; - LPUNKNOWN lpUnkDDSTarget; -} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW; -typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW; - -DECL_WINELIB_TYPE_AW(DICONFIGUREDEVICESPARAMS) -DECL_WINELIB_TYPE_AW(LPDICONFIGUREDEVICESPARAMS) -DECL_WINELIB_TYPE_AW(LPCDICONFIGUREDEVICESPARAMS) - -#define DIDIFT_CONFIGURATION 0x00000001 -#define DIDIFT_OVERLAY 0x00000002 - -#define DIDAL_CENTERED 0x00000000 -#define DIDAL_LEFTALIGNED 0x00000001 -#define DIDAL_RIGHTALIGNED 0x00000002 -#define DIDAL_MIDDLE 0x00000000 -#define DIDAL_TOPALIGNED 0x00000004 -#define DIDAL_BOTTOMALIGNED 0x00000008 - -typedef struct _DIDEVICEIMAGEINFOA { - CHAR tszImagePath[MAX_PATH]; - DWORD dwFlags; - DWORD dwViewID; - RECT rcOverlay; - DWORD dwObjID; - DWORD dwcValidPts; - POINT rgptCalloutLine[5]; - RECT rcCalloutRect; - DWORD dwTextAlign; -} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA; -typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA; - -typedef struct _DIDEVICEIMAGEINFOW { - WCHAR tszImagePath[MAX_PATH]; - DWORD dwFlags; - DWORD dwViewID; - RECT rcOverlay; - DWORD dwObjID; - DWORD dwcValidPts; - POINT rgptCalloutLine[5]; - RECT rcCalloutRect; - DWORD dwTextAlign; -} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW; -typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW; - -DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFO) -DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFO) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFO) - -typedef struct _DIDEVICEIMAGEINFOHEADERA { - DWORD dwSize; - DWORD dwSizeImageInfo; - DWORD dwcViews; - DWORD dwcButtons; - DWORD dwcAxes; - DWORD dwcPOVs; - DWORD dwBufferSize; - DWORD dwBufferUsed; - LPDIDEVICEIMAGEINFOA lprgImageInfoArray; -} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA; -typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA; - -typedef struct _DIDEVICEIMAGEINFOHEADERW { - DWORD dwSize; - DWORD dwSizeImageInfo; - DWORD dwcViews; - DWORD dwcButtons; - DWORD dwcAxes; - DWORD dwcPOVs; - DWORD dwBufferSize; - DWORD dwBufferUsed; - LPDIDEVICEIMAGEINFOW lprgImageInfoArray; -} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW; -typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW; - -DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFOHEADER) -DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFOHEADER) -DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFOHEADER) - -#endif /* DI8 */ - - -/***************************************************************************** - * IDirectInputEffect interface - */ -#if (DIRECTINPUT_VERSION >= 0x0500) -#undef INTERFACE -#define INTERFACE IDirectInputEffect -DECLARE_INTERFACE_(IDirectInputEffect,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputEffect methods ***/ - STDMETHOD(Initialize)(THIS_ HINSTANCE, DWORD, REFGUID) PURE; - STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE; - STDMETHOD(GetParameters)(THIS_ LPDIEFFECT, DWORD) PURE; - STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT, DWORD) PURE; - STDMETHOD(Start)(THIS_ DWORD, DWORD) PURE; - STDMETHOD(Stop)(THIS) PURE; - STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE; - STDMETHOD(Download)(THIS) PURE; - STDMETHOD(Unload)(THIS) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputEffect_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputEffect_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputEffect methods ***/ -#define IDirectInputEffect_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputEffect_GetEffectGuid(p,a) (p)->lpVtbl->GetEffectGuid(p,a) -#define IDirectInputEffect_GetParameters(p,a,b) (p)->lpVtbl->GetParameters(p,a,b) -#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b) -#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b) -#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p) -#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a) -#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p) -#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p) -#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#else -/*** IUnknown methods ***/ -#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputEffect_AddRef(p) (p)->AddRef() -#define IDirectInputEffect_Release(p) (p)->Release() -/*** IDirectInputEffect methods ***/ -#define IDirectInputEffect_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputEffect_GetEffectGuid(p,a) (p)->GetEffectGuid(a) -#define IDirectInputEffect_GetParameters(p,a,b) (p)->GetParameters(a,b) -#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b) -#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b) -#define IDirectInputEffect_Stop(p) (p)->Stop() -#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a) -#define IDirectInputEffect_Download(p) (p)->Download() -#define IDirectInputEffect_Unload(p) (p)->Unload() -#define IDirectInputEffect_Escape(p,a) (p)->Escape(a) -#endif - -#endif /* DI5 */ - - -/***************************************************************************** - * IDirectInputDeviceA interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDeviceA -DECLARE_INTERFACE_(IDirectInputDeviceA,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; -}; - -/***************************************************************************** - * IDirectInputDeviceW interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDeviceW -DECLARE_INTERFACE_(IDirectInputDeviceW,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#else -/*** IUnknown methods ***/ -#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice_AddRef(p) (p)->AddRef() -#define IDirectInputDevice_Release(p) (p)->Release() -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice_Acquire(p) (p)->Acquire() -#define IDirectInputDevice_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#endif - - -#if (DIRECTINPUT_VERSION >= 0x0500) -/***************************************************************************** - * IDirectInputDevice2A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice2A -DECLARE_INTERFACE_(IDirectInputDevice2A,IDirectInputDeviceA) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; -}; - -/***************************************************************************** - * IDirectInputDevice2W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice2W -DECLARE_INTERFACE_(IDirectInputDevice2W,IDirectInputDeviceW) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice2_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice2_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice2_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice2_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice2_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice2_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice2_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice2_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice2_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice2_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -#else -/*** IUnknown methods ***/ -#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice2_AddRef(p) (p)->AddRef() -#define IDirectInputDevice2_Release(p) (p)->Release() -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice2_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice2_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice2_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice2_Acquire(p) (p)->Acquire() -#define IDirectInputDevice2_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice2_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice2_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice2_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice2_Poll(p) (p)->Poll() -#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -#endif -#endif /* DI5 */ - -#if DIRECTINPUT_VERSION >= 0x0700 -/***************************************************************************** - * IDirectInputDevice7A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice7A -DECLARE_INTERFACE_(IDirectInputDevice7A,IDirectInputDevice2A) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; - /*** IDirectInputDevice7A methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE; -}; - -/***************************************************************************** - * IDirectInputDevice7W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice7W -DECLARE_INTERFACE_(IDirectInputDevice7W,IDirectInputDevice2W) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; - /*** IDirectInputDevice7W methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice7_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice7_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice7_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice7_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice7_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice7_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice7_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice7_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice7_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice7_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -/*** IDirectInputDevice7 methods ***/ -#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) -#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) -#else -/*** IUnknown methods ***/ -#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice7_AddRef(p) (p)->AddRef() -#define IDirectInputDevice7_Release(p) (p)->Release() -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice7_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice7_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice7_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice7_Acquire(p) (p)->Acquire() -#define IDirectInputDevice7_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice7_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice7_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice7_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice7_Poll(p) (p)->Poll() -#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -/*** IDirectInputDevice7 methods ***/ -#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) -#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) -#endif - -#endif /* DI7 */ - -#if DIRECTINPUT_VERSION >= 0x0800 -/***************************************************************************** - * IDirectInputDevice8A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice8A -DECLARE_INTERFACE_(IDirectInputDevice8A,IDirectInputDevice7A) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; - /*** IDirectInputDevice7A methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE; - /*** IDirectInputDevice8A methods ***/ - STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE; - STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE; - STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) PURE; -}; - -/***************************************************************************** - * IDirectInputDevice8W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputDevice8W -DECLARE_INTERFACE_(IDirectInputDevice8W,IDirectInputDevice7W) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE; - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE; - /*** IDirectInputDevice7W methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE; - /*** IDirectInputDevice8W methods ***/ - STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE; - STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE; - STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice8_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice8_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice8_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice8_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice8_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice8_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice8_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice8_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice8_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice8_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -/*** IDirectInputDevice7 methods ***/ -#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) -#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) -/*** IDirectInputDevice8 methods ***/ -#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c) -#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->lpVtbl->SetActionMap(p,a,b,c) -#define IDirectInputDevice8_GetImageInfo(p,a) (p)->lpVtbl->GetImageInfo(p,a) -#else -/*** IUnknown methods ***/ -#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice8_AddRef(p) (p)->AddRef() -#define IDirectInputDevice8_Release(p) (p)->Release() -/*** IDirectInputDevice methods ***/ -#define IDirectInputDevice8_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice8_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice8_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice8_Acquire(p) (p)->Acquire() -#define IDirectInputDevice8_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice8_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice8_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -/*** IDirectInputDevice2 methods ***/ -#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice8_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice8_Poll(p) (p)->Poll() -#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -/*** IDirectInputDevice7 methods ***/ -#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) -#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) -/*** IDirectInputDevice8 methods ***/ -#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c) -#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->SetActionMap(a,b,c) -#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a) -#endif - -#endif /* DI8 */ - -/* "Standard" Mouse report... */ -typedef struct DIMOUSESTATE { - LONG lX; - LONG lY; - LONG lZ; - BYTE rgbButtons[4]; -} DIMOUSESTATE; - -#if DIRECTINPUT_VERSION >= 0x0700 -/* "Standard" Mouse report for DInput 7... */ -typedef struct DIMOUSESTATE2 { - LONG lX; - LONG lY; - LONG lZ; - BYTE rgbButtons[8]; -} DIMOUSESTATE2; -#endif /* DI7 */ - -#define DIMOFS_X FIELD_OFFSET(DIMOUSESTATE, lX) -#define DIMOFS_Y FIELD_OFFSET(DIMOUSESTATE, lY) -#define DIMOFS_Z FIELD_OFFSET(DIMOUSESTATE, lZ) -#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0) -#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1) -#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2) -#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3) -#if DIRECTINPUT_VERSION >= 0x0700 -#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4) -#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5) -#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6) -#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7) -#endif /* DI7 */ - -#ifdef __cplusplus -extern "C" { -#endif -extern const DIDATAFORMAT c_dfDIMouse; -#if DIRECTINPUT_VERSION >= 0x0700 -extern const DIDATAFORMAT c_dfDIMouse2; /* DX 7 */ -#endif /* DI7 */ -extern const DIDATAFORMAT c_dfDIKeyboard; -#if DIRECTINPUT_VERSION >= 0x0500 -extern const DIDATAFORMAT c_dfDIJoystick; -extern const DIDATAFORMAT c_dfDIJoystick2; -#endif /* DI5 */ -#ifdef __cplusplus -}; -#endif - -/***************************************************************************** - * IDirectInputA interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputA -DECLARE_INTERFACE_(IDirectInputA,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; -}; - -/***************************************************************************** - * IDirectInputW interface - */ -#undef INTERFACE -#define INTERFACE IDirectInputW -DECLARE_INTERFACE_(IDirectInputW,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInput methods ***/ -#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#else -/*** IUnknown methods ***/ -#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput_AddRef(p) (p)->AddRef() -#define IDirectInput_Release(p) (p)->Release() -/*** IDirectInput methods ***/ -#define IDirectInput_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput_Initialize(p,a,b) (p)->Initialize(a,b) -#endif - -/***************************************************************************** - * IDirectInput2A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput2A -DECLARE_INTERFACE_(IDirectInput2A,IDirectInputA) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - /*** IDirectInput2A methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE; -}; - -/***************************************************************************** - * IDirectInput2W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput2W -DECLARE_INTERFACE_(IDirectInput2W,IDirectInputW) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - /*** IDirectInput2W methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInput methods ***/ -#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -/*** IDirectInput2 methods ***/ -#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#else -/*** IUnknown methods ***/ -#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput2_AddRef(p) (p)->AddRef() -#define IDirectInput2_Release(p) (p)->Release() -/*** IDirectInput methods ***/ -#define IDirectInput2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput2_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput2_Initialize(p,a,b) (p)->Initialize(a,b) -/*** IDirectInput2 methods ***/ -#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#endif - -/***************************************************************************** - * IDirectInput7A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput7A -DECLARE_INTERFACE_(IDirectInput7A,IDirectInput2A) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - /*** IDirectInput2A methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE; - /*** IDirectInput7A methods ***/ - STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE; -}; - -/***************************************************************************** - * IDirectInput7W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput7W -DECLARE_INTERFACE_(IDirectInput7W,IDirectInput2W) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - /*** IDirectInput2W methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE; - /*** IDirectInput7W methods ***/ - STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInput methods ***/ -#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -/*** IDirectInput2 methods ***/ -#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -/*** IDirectInput7 methods ***/ -#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d) -#else -/*** IUnknown methods ***/ -#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput7_AddRef(p) (p)->AddRef() -#define IDirectInput7_Release(p) (p)->Release() -/*** IDirectInput methods ***/ -#define IDirectInput7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput7_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput7_Initialize(p,a,b) (p)->Initialize(a,b) -/*** IDirectInput2 methods ***/ -#define IDirectInput7_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -/*** IDirectInput7 methods ***/ -#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d) -#endif - - -#if DIRECTINPUT_VERSION >= 0x0800 -/***************************************************************************** - * IDirectInput8A interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput8A -DECLARE_INTERFACE_(IDirectInput8A,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInput8A methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8A *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE; - STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE; -}; - -/***************************************************************************** - * IDirectInput8W interface - */ -#undef INTERFACE -#define INTERFACE IDirectInput8W -DECLARE_INTERFACE_(IDirectInput8W,IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - /*** IDirectInput8W methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE; - STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE; - STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE; -}; -#undef INTERFACE - -#if !defined(__cplusplus) || defined(CINTERFACE) -/*** IUnknown methods ***/ -#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p) -/*** IDirectInput8 methods ***/ -#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e) -#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d) -#else -/*** IUnknown methods ***/ -#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput8_AddRef(p) (p)->AddRef() -#define IDirectInput8_Release(p) (p)->Release() -/*** IDirectInput8 methods ***/ -#define IDirectInput8_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput8_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput8_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectInput8_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e) -#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d) -#endif - -#endif /* DI8 */ - -/* Export functions */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if DIRECTINPUT_VERSION >= 0x0800 -HRESULT WINAPI DirectInput8Create(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN); -#else /* DI < 8 */ -HRESULT WINAPI DirectInputCreateA(HINSTANCE,DWORD,LPDIRECTINPUTA *,LPUNKNOWN); -HRESULT WINAPI DirectInputCreateW(HINSTANCE,DWORD,LPDIRECTINPUTW *,LPUNKNOWN); -#define DirectInputCreate WINELIB_NAME_AW(DirectInputCreate) - -HRESULT WINAPI DirectInputCreateEx(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN); -#endif /* DI8 */ - -#ifdef __cplusplus -}; -#endif - -#endif /* __DINPUT_INCLUDED__ */ diff --git a/deps/mingw/xinput.h b/deps/mingw/xinput.h deleted file mode 100644 index d3ca726ce..000000000 --- a/deps/mingw/xinput.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * The Wine project - Xinput Joystick Library - * Copyright 2008 Andrew Fenn - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef __WINE_XINPUT_H -#define __WINE_XINPUT_H - -#include - -/* - * Bitmasks for the joysticks buttons, determines what has - * been pressed on the joystick, these need to be mapped - * to whatever device you're using instead of an xbox 360 - * joystick - */ - -#define XINPUT_GAMEPAD_DPAD_UP 0x0001 -#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002 -#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004 -#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 -#define XINPUT_GAMEPAD_START 0x0010 -#define XINPUT_GAMEPAD_BACK 0x0020 -#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040 -#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 -#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 -#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 -#define XINPUT_GAMEPAD_A 0x1000 -#define XINPUT_GAMEPAD_B 0x2000 -#define XINPUT_GAMEPAD_X 0x4000 -#define XINPUT_GAMEPAD_Y 0x8000 - -/* - * Defines the flags used to determine if the user is pushing - * down on a button, not holding a button, etc - */ - -#define XINPUT_KEYSTROKE_KEYDOWN 0x0001 -#define XINPUT_KEYSTROKE_KEYUP 0x0002 -#define XINPUT_KEYSTROKE_REPEAT 0x0004 - -/* - * Defines the codes which are returned by XInputGetKeystroke - */ - -#define VK_PAD_A 0x5800 -#define VK_PAD_B 0x5801 -#define VK_PAD_X 0x5802 -#define VK_PAD_Y 0x5803 -#define VK_PAD_RSHOULDER 0x5804 -#define VK_PAD_LSHOULDER 0x5805 -#define VK_PAD_LTRIGGER 0x5806 -#define VK_PAD_RTRIGGER 0x5807 -#define VK_PAD_DPAD_UP 0x5810 -#define VK_PAD_DPAD_DOWN 0x5811 -#define VK_PAD_DPAD_LEFT 0x5812 -#define VK_PAD_DPAD_RIGHT 0x5813 -#define VK_PAD_START 0x5814 -#define VK_PAD_BACK 0x5815 -#define VK_PAD_LTHUMB_PRESS 0x5816 -#define VK_PAD_RTHUMB_PRESS 0x5817 -#define VK_PAD_LTHUMB_UP 0x5820 -#define VK_PAD_LTHUMB_DOWN 0x5821 -#define VK_PAD_LTHUMB_RIGHT 0x5822 -#define VK_PAD_LTHUMB_LEFT 0x5823 -#define VK_PAD_LTHUMB_UPLEFT 0x5824 -#define VK_PAD_LTHUMB_UPRIGHT 0x5825 -#define VK_PAD_LTHUMB_DOWNRIGHT 0x5826 -#define VK_PAD_LTHUMB_DOWNLEFT 0x5827 -#define VK_PAD_RTHUMB_UP 0x5830 -#define VK_PAD_RTHUMB_DOWN 0x5831 -#define VK_PAD_RTHUMB_RIGHT 0x5832 -#define VK_PAD_RTHUMB_LEFT 0x5833 -#define VK_PAD_RTHUMB_UPLEFT 0x5834 -#define VK_PAD_RTHUMB_UPRIGHT 0x5835 -#define VK_PAD_RTHUMB_DOWNRIGHT 0x5836 -#define VK_PAD_RTHUMB_DOWNLEFT 0x5837 - -/* - * Deadzones are for analogue joystick controls on the joypad - * which determine when input should be assumed to be in the - * middle of the pad. This is a threshold to stop a joypad - * controlling the game when the player isn't touching the - * controls. - */ - -#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849 -#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689 -#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30 - - -/* - * Defines what type of abilities the type of joystick has - * DEVTYPE_GAMEPAD is available for all joysticks, however - * there may be more specific identifiers for other joysticks - * which are being used. - */ - -#define XINPUT_DEVTYPE_GAMEPAD 0x01 -#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01 -#define XINPUT_DEVSUBTYPE_WHEEL 0x02 -#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03 -#define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04 -#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05 -#define XINPUT_DEVSUBTYPE_GUITAR 0x06 -#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08 - -/* - * These are used with the XInputGetCapabilities function to - * determine the abilities to the joystick which has been - * plugged in. - */ - -#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004 -#define XINPUT_FLAG_GAMEPAD 0x00000001 - -/* - * Defines the status of the battery if one is used in the - * attached joystick. The first two define if the joystick - * supports a battery. Disconnected means that the joystick - * isn't connected. Wired shows that the joystick is a wired - * joystick. - */ - -#define BATTERY_DEVTYPE_GAMEPAD 0x00 -#define BATTERY_DEVTYPE_HEADSET 0x01 -#define BATTERY_TYPE_DISCONNECTED 0x00 -#define BATTERY_TYPE_WIRED 0x01 -#define BATTERY_TYPE_ALKALINE 0x02 -#define BATTERY_TYPE_NIMH 0x03 -#define BATTERY_TYPE_UNKNOWN 0xFF -#define BATTERY_LEVEL_EMPTY 0x00 -#define BATTERY_LEVEL_LOW 0x01 -#define BATTERY_LEVEL_MEDIUM 0x02 -#define BATTERY_LEVEL_FULL 0x03 - -/* - * How many joysticks can be used with this library. Games that - * use the xinput library will not go over this number. - */ - -#define XUSER_MAX_COUNT 4 -#define XUSER_INDEX_ANY 0x000000FF - -/* - * Defines the structure of an xbox 360 joystick. - */ - -typedef struct _XINPUT_GAMEPAD { - WORD wButtons; - BYTE bLeftTrigger; - BYTE bRightTrigger; - SHORT sThumbLX; - SHORT sThumbLY; - SHORT sThumbRX; - SHORT sThumbRY; -} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD; - -typedef struct _XINPUT_STATE { - DWORD dwPacketNumber; - XINPUT_GAMEPAD Gamepad; -} XINPUT_STATE, *PXINPUT_STATE; - -/* - * Defines the structure of how much vibration is set on both the - * right and left motors in a joystick. If you're not using a 360 - * joystick you will have to map these to your device. - */ - -typedef struct _XINPUT_VIBRATION { - WORD wLeftMotorSpeed; - WORD wRightMotorSpeed; -} XINPUT_VIBRATION, *PXINPUT_VIBRATION; - -/* - * Defines the structure for what kind of abilities the joystick has - * such abilities are things such as if the joystick has the ability - * to send and receive audio, if the joystick is in fact a driving - * wheel or perhaps if the joystick is some kind of dance pad or - * guitar. - */ - -typedef struct _XINPUT_CAPABILITIES { - BYTE Type; - BYTE SubType; - WORD Flags; - XINPUT_GAMEPAD Gamepad; - XINPUT_VIBRATION Vibration; -} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES; - -/* - * Defines the structure for a joystick input event which is - * retrieved using the function XInputGetKeystroke - */ -typedef struct _XINPUT_KEYSTROKE { - WORD VirtualKey; - WCHAR Unicode; - WORD Flags; - BYTE UserIndex; - BYTE HidCode; -} XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE; - -typedef struct _XINPUT_BATTERY_INFORMATION -{ - BYTE BatteryType; - BYTE BatteryLevel; -} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION; - -#ifdef __cplusplus -extern "C" { -#endif - -void WINAPI XInputEnable(WINBOOL); -DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*); -DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*); -DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE); -DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*); -DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*); -DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*); - -#ifdef __cplusplus -} -#endif - -#endif /* __WINE_XINPUT_H */ diff --git a/docs/compile.md b/docs/compile.md index 6b0b71227..3b10ea575 100644 --- a/docs/compile.md +++ b/docs/compile.md @@ -36,9 +36,9 @@ specific to GLFW. It may be a useful companion to this one. ### 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. +The C/C++ development environments in Visual Studio, Xcode and MinGW-w64 come +with all necessary dependencies for compiling GLFW, but on Unix-like systems +like Linux and FreeBSD you will need a few extra packages. #### Dependencies for Wayland and X11 {#compile_deps_wayland} @@ -180,7 +180,7 @@ cd path/to/build make ``` -With MinGW, it is `mingw32-make`. +With MinGW-w64, it is `mingw32-make`. ```sh cd path/to/build @@ -299,12 +299,12 @@ library. This option is only available when compiling for Linux and other Unix- systems other than macOS. This is enabled by default. -## Cross-compilation with CMake and MinGW {#compile_mingw_cross} +## Cross-compilation with CMake and MinGW-w64 {#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 -for 32- and 64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives -like Ubuntu have the `mingw-w64` package for both. +Both Cygwin and many Linux distributions have MinGW-w64 packages. For example, +Cygwin has the `mingw64-i686-gcc` and `mingw64-x86_64-gcc` packages for 32- and +64-bit version of MinGW-w64, while Debian GNU/Linux and derivatives like Ubuntu +have the `mingw-w64` package for both. GLFW has CMake toolchain files in the `CMake` subdirectory that set up cross-compilation of Windows binaries. To use these files you set the @@ -315,9 +315,9 @@ configuring and generating the build files. cmake -S path/to/glfw -B path/to/build -D CMAKE_TOOLCHAIN_FILE=path/to/file ``` -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 -directory. For example, both the Ubuntu and Cygwin MinGW-w64 packages have +The exact toolchain file to use depends on the prefix used by the MinGW-w64 +binaries on your system. You can usually see this in the /usr 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: diff --git a/docs/intro.md b/docs/intro.md index 7aa75e31e..f2060c330 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -621,11 +621,11 @@ 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.5 with MinGW as a DLL for Windows, may result in a version string -like this: +For example, compiling GLFW 3.5 with MinGW-64 as a DLL for Windows, may result +in a version string like this: ```c -3.5.0 Win32 WGL Null EGL OSMesa MinGW DLL +3.5.0 Win32 WGL Null EGL OSMesa MinGW-w64 DLL ``` Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may diff --git a/docs/news.md b/docs/news.md index 148d08712..e98e2a770 100644 --- a/docs/news.md +++ b/docs/news.md @@ -20,6 +20,15 @@ this. ## Removals {#removals} +### Original MinGW support has been removed {#original_mingw} + +Support for the now unmaintained original MinGW distribution has been removed. + +This does not apply to the much more capable [MinGW-w64](https://www.mingw-w64.org/), +which remains fully supported. MinGW-w64 can build both 32- and 64-bit binaries, is +actively maintained and available on many platforms. + + ## New symbols {#new_symbols} ### New functions {#new_functions} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a085b2b6..2cbe8a733 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -255,24 +255,6 @@ if (GLFW_BUILD_WIN32) target_compile_definitions(glfw PRIVATE UNICODE _UNICODE) endif() -# HACK: When building on MinGW, WINVER and UNICODE need to be defined before -# the inclusion of stddef.h (by glfw3.h), which is itself included before -# win32_platform.h. We define them here until a saner solution can be found -# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack. -if (MINGW) - target_compile_definitions(glfw PRIVATE WINVER=0x0501) -endif() - -# Workaround for legacy MinGW not providing XInput and DirectInput -if (MINGW) - include(CheckIncludeFile) - check_include_file(dinput.h DINPUT_H_FOUND) - check_include_file(xinput.h XINPUT_H_FOUND) - if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND) - target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw") - endif() -endif() - # Workaround for the MS CRT deprecating parts of the standard library if (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) @@ -286,10 +268,6 @@ endif() if (GLFW_BUILD_SHARED_LIBRARY) if (WIN32) if (MINGW) - # Remove the dependency on the shared version of libgcc - # NOTE: MinGW-w64 has the correct default but MinGW needs this - target_link_libraries(glfw PRIVATE "-static-libgcc") - # Remove the lib prefix on the DLL (but not the import library) set_target_properties(glfw PROPERTIES PREFIX "") diff --git a/src/platform.c b/src/platform.c index 9ca64963e..95b8d0b58 100644 --- a/src/platform.c +++ b/src/platform.c @@ -187,8 +187,6 @@ GLFWAPI const char* glfwGetVersionString(void) " OSMesa" #if defined(__MINGW64_VERSION_MAJOR) " MinGW-w64" -#elif defined(__MINGW32__) - " MinGW" #elif defined(_MSC_VER) " VisualC" #endif diff --git a/src/win32_platform.h b/src/win32_platform.h index a2f868527..bcbc604b4 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -83,24 +83,12 @@ #ifndef WM_COPYGLOBALDATA #define WM_COPYGLOBALDATA 0x0049 #endif -#ifndef WM_UNICHAR - #define WM_UNICHAR 0x0109 -#endif -#ifndef UNICODE_NOCHAR - #define UNICODE_NOCHAR 0xFFFF -#endif #ifndef WM_DPICHANGED #define WM_DPICHANGED 0x02E0 #endif -#ifndef GET_XBUTTON_WPARAM - #define GET_XBUTTON_WPARAM(w) (HIWORD(w)) -#endif #ifndef EDS_ROTATEDMODE #define EDS_ROTATEDMODE 0x00000004 #endif -#ifndef DISPLAY_DEVICE_ACTIVE - #define DISPLAY_DEVICE_ACTIVE 0x00000001 -#endif #ifndef _WIN32_WINNT_WINBLUE #define _WIN32_WINNT_WINBLUE 0x0603 #endif @@ -113,9 +101,6 @@ #ifndef USER_DEFAULT_SCREEN_DPI #define USER_DEFAULT_SCREEN_DPI 96 #endif -#ifndef OCR_HAND - #define OCR_HAND 32649 -#endif #if WINVER < 0x0601 typedef struct From d11cb3779b828116af6391dfc07c147fa5e0a1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 4 Apr 2024 16:40:27 +0200 Subject: [PATCH 027/112] Win32: Remove support for Windows XP and Vista It's increasingly difficult to maintain a safe testing environment for Windows XP, and so increasingly a burden on contributors to maintain support for it. Windows XP has been out of of support since 2014 and should not be used as a desktop OS. Fixes #2505 --- README.md | 3 ++- docs/news.md | 6 +++++ src/wgl_context.c | 10 ++++---- src/win32_init.c | 6 +---- src/win32_platform.h | 57 +++++--------------------------------------- src/win32_window.c | 19 +++------------ 6 files changed, 23 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index 344d61954..718449f5e 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ more information. ## System requirements -GLFW supports Windows XP and later and macOS 10.11 and later. Linux and other +GLFW supports Windows 7 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. @@ -125,6 +125,7 @@ information on what to include when reporting a bug. the limit of the mouse button tokens to be reported (#2423) - Updated minimum CMake version to 3.16 (#2541) - Removed support for building with original MinGW (#2540) + - [Win32] Removed support for Windows XP and Vista (#2505) - [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 diff --git a/docs/news.md b/docs/news.md index e98e2a770..640ae7a57 100644 --- a/docs/news.md +++ b/docs/news.md @@ -20,6 +20,12 @@ this. ## Removals {#removals} +### Windows XP and Vista support has been removed {#winxp_vista} + +Support for Windows XP and Vista has been removed. Windows XP has been out of extended +support since 2014. + + ### Original MinGW support has been removed {#original_mingw} Support for the now unmaintained original MinGW distribution has been removed. diff --git a/src/wgl_context.c b/src/wgl_context.c index 1c9189fab..3c7d71c23 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -327,8 +327,8 @@ static void swapBuffersWGL(_GLFWwindow* window) { if (!window->monitor) { - // HACK: Use DwmFlush when desktop composition is enabled on Windows Vista and 7 - if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater()) + // HACK: Use DwmFlush when desktop composition is enabled on Windows 7 + if (!IsWindows8OrGreater()) { BOOL enabled = FALSE; @@ -353,9 +353,9 @@ static void swapIntervalWGL(int interval) if (!window->monitor) { - // HACK: Disable WGL swap interval when desktop composition is enabled on Windows - // Vista and 7 to avoid interfering with DWM vsync - if (!IsWindows8OrGreater() && IsWindowsVistaOrGreater()) + // HACK: Disable WGL swap interval when desktop composition is enabled on + // Windows 7 to avoid interfering with DWM vsync + if (!IsWindows8OrGreater()) { BOOL enabled = FALSE; diff --git a/src/win32_init.c b/src/win32_init.c index 77ab56bab..6b6e9d08e 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -89,10 +89,6 @@ static GLFWbool loadLibraries(void) return GLFW_FALSE; } - _glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware) - _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "SetProcessDPIAware"); - _glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx) - _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx"); _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling) _glfwPlatformGetModuleSymbol(_glfw.win32.user32.instance, "EnableNonClientDpiScaling"); _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext) @@ -692,7 +688,7 @@ int _glfwInitWin32(void) SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); else if (IsWindows8Point1OrGreater()) SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); - else if (IsWindowsVistaOrGreater()) + else SetProcessDPIAware(); if (!createHelperWindow()) diff --git a/src/win32_platform.h b/src/win32_platform.h index bcbc604b4..49cceba6d 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -48,14 +48,14 @@ #define UNICODE #endif -// GLFW requires Windows XP or later -#if WINVER < 0x0501 +// GLFW requires Windows 7 or later +#if WINVER < 0x0601 #undef WINVER - #define WINVER 0x0501 + #define WINVER 0x0601 #endif -#if _WIN32_WINNT < 0x0501 +#if _WIN32_WINNT < 0x0601 #undef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 + #define _WIN32_WINNT 0x0601 #endif // GLFW uses DirectInput8 interfaces @@ -66,20 +66,12 @@ #include #include +#include #include #include #include // HACK: Define macros that some windows.h variants don't -#ifndef WM_MOUSEHWHEEL - #define WM_MOUSEHWHEEL 0x020E -#endif -#ifndef WM_DWMCOMPOSITIONCHANGED - #define WM_DWMCOMPOSITIONCHANGED 0x031E -#endif -#ifndef WM_DWMCOLORIZATIONCOLORCHANGED - #define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320 -#endif #ifndef WM_COPYGLOBALDATA #define WM_COPYGLOBALDATA 0x0049 #endif @@ -102,31 +94,6 @@ #define USER_DEFAULT_SCREEN_DPI 96 #endif -#if WINVER < 0x0601 -typedef struct -{ - DWORD cbSize; - DWORD ExtStatus; -} CHANGEFILTERSTRUCT; -#ifndef MSGFLT_ALLOW - #define MSGFLT_ALLOW 1 -#endif -#endif /*Windows 7*/ - -#if WINVER < 0x0600 -#define DWM_BB_ENABLE 0x00000001 -#define DWM_BB_BLURREGION 0x00000002 -typedef struct -{ - DWORD dwFlags; - BOOL fEnable; - HRGN hRgnBlur; - BOOL fTransitionOnMaximized; -} DWM_BLURBEHIND; -#else - #include -#endif /*Windows Vista*/ - #ifndef DPI_ENUMS_DECLARED typedef enum { @@ -150,12 +117,6 @@ typedef enum // Replacement for versionhelpers.h macros, as we cannot rely on the // application having a correct embedded manifest // -#define IsWindowsVistaOrGreater() \ - _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \ - LOBYTE(_WIN32_WINNT_VISTA), 0) -#define IsWindows7OrGreater() \ - _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7), \ - LOBYTE(_WIN32_WINNT_WIN7), 0) #define IsWindows8OrGreater() \ _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \ LOBYTE(_WIN32_WINNT_WIN8), 0) @@ -266,15 +227,11 @@ typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID* #define DirectInput8Create _glfw.win32.dinput8.Create // user32.dll function pointer typedefs -typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void); -typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*); typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND); typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE); typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND); typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT); typedef int (WINAPI * PFN_GetSystemMetricsForDpi)(int,UINT); -#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_ -#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_ #define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_ #define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_ #define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_ @@ -460,8 +417,6 @@ typedef struct _GLFWlibraryWin32 struct { HINSTANCE instance; - PFN_SetProcessDPIAware SetProcessDPIAware_; - PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_; PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_; PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_; PFN_GetDpiForWindow GetDpiForWindow_; diff --git a/src/win32_window.c b/src/win32_window.c index d014944b8..26f9684b7 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -374,9 +374,6 @@ static void updateFramebufferTransparency(const _GLFWwindow* window) BOOL composition, opaque; DWORD color; - if (!IsWindowsVistaOrGreater()) - return; - if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition) return; @@ -983,7 +980,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l case WM_MOUSEHWHEEL: { - // This message is only sent on Windows Vista and later // NOTE: The X-axis is inverted for consistency with macOS and X11 _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0); return 0; @@ -1407,15 +1403,9 @@ static int createNativeWindow(_GLFWwindow* window, SetPropW(window->win32.handle, L"GLFW", window); - if (IsWindows7OrGreater()) - { - ChangeWindowMessageFilterEx(window->win32.handle, - WM_DROPFILES, MSGFLT_ALLOW, NULL); - ChangeWindowMessageFilterEx(window->win32.handle, - WM_COPYDATA, MSGFLT_ALLOW, NULL); - ChangeWindowMessageFilterEx(window->win32.handle, - WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL); - } + ChangeWindowMessageFilterEx(window->win32.handle, WM_DROPFILES, MSGFLT_ALLOW, NULL); + ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYDATA, MSGFLT_ALLOW, NULL); + ChangeWindowMessageFilterEx(window->win32.handle, WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL); window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.keymenu = wndconfig->win32.keymenu; @@ -1981,9 +1971,6 @@ GLFWbool _glfwFramebufferTransparentWin32(_GLFWwindow* window) if (!window->win32.transparent) return GLFW_FALSE; - if (!IsWindowsVistaOrGreater()) - return GLFW_FALSE; - if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition) return GLFW_FALSE; From feb2a6b7283cbea73d92410dbddf3cc83dcc957f Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Wed, 16 Jul 2025 14:19:19 +0200 Subject: [PATCH 028/112] Wayland: Reset key repeat timer on window destruction Windows with keyboard focus may have an active key repeat timer. This should be reset when the window is closed, or key repeat events could be sent to a NULL window were it not for the quickfix in PR #2732. Fixes #2741 Probably the source of #2727 --- README.md | 1 + src/wl_window.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 718449f5e..e7ad5a0cd 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517) - [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) + - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_window.c b/src/wl_window.c index 6457f31e0..01650182c 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2187,7 +2187,12 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) _glfw.wl.pointerFocus = NULL; if (window == _glfw.wl.keyboardFocus) + { + struct itimerspec timer = {0}; + timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); + _glfw.wl.keyboardFocus = NULL; + } if (window->wl.fractionalScale) wp_fractional_scale_v1_destroy(window->wl.fractionalScale); From ac10768495837eb98da27d01fe706073d6d251c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 17 Jul 2025 13:07:52 +0200 Subject: [PATCH 029/112] Wayland: Fix memory leaks in data offer reading The buffer storing the contents of the data offer being read could leak if buffer reallocation or reading from the pipe failed. --- README.md | 1 + src/wl_window.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index e7ad5a0cd..c453739d0 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) + - [Wayland] Bugfix: Memory would leak if reading a data offer failed midway - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_window.c b/src/wl_window.c index 01650182c..def3b8704 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1333,6 +1333,7 @@ static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mime if (!longer) { _glfwInputError(GLFW_OUT_OF_MEMORY, NULL); + _glfw_free(string); close(fds[0]); return NULL; } @@ -1352,6 +1353,7 @@ static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mime _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to read from data offer pipe: %s", strerror(errno)); + _glfw_free(string); close(fds[0]); return NULL; } From 7b51a8eb315ba8221ee0cd37d6b8641e75cddadb Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sun, 10 Aug 2025 18:27:44 +0200 Subject: [PATCH 030/112] Wayland: Keyboard leave event handler now processes key repeats - Fixes #2736 --- README.md | 1 + src/wl_window.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/README.md b/README.md index c453739d0..456c75333 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) - [Wayland] Bugfix: Memory would leak if reading a data offer failed midway + - [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_window.c b/src/wl_window.c index def3b8704..7e15a3d01 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1760,6 +1760,24 @@ static void keyboardHandleLeave(void* userData, if (!window) return; + // Handle any key repeats up to this point. We don't poll as this should be infrequent. + uint64_t repeats; + if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8) + { + if(_glfw.wl.keyboardFocus) + { + for (uint64_t i = 0; i < repeats; i++) + { + _glfwInputKey(_glfw.wl.keyboardFocus, + translateKey(_glfw.wl.keyRepeatScancode), + _glfw.wl.keyRepeatScancode, + GLFW_PRESS, + _glfw.wl.xkb.modifiers); + inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); + } + } + } + struct itimerspec timer = {0}; timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); From 5245180c56120f05b75ecd2ba4933bd04890ebba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 21 Jul 2025 18:41:06 +0200 Subject: [PATCH 031/112] Formatting --- src/wl_platform.h | 80 +++++++++++++++++++++++------------------------ src/wl_window.c | 8 ++--- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index afa6f50af..eb68f7e8f 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -217,62 +217,62 @@ struct libdecor_configuration; enum libdecor_error { - LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, - LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION, + LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, + LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION, }; enum libdecor_window_state { - LIBDECOR_WINDOW_STATE_NONE = 0, - LIBDECOR_WINDOW_STATE_ACTIVE = 1, - LIBDECOR_WINDOW_STATE_MAXIMIZED = 2, - LIBDECOR_WINDOW_STATE_FULLSCREEN = 4, - LIBDECOR_WINDOW_STATE_TILED_LEFT = 8, - LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16, - LIBDECOR_WINDOW_STATE_TILED_TOP = 32, - LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64 + LIBDECOR_WINDOW_STATE_NONE = 0, + LIBDECOR_WINDOW_STATE_ACTIVE = 1, + LIBDECOR_WINDOW_STATE_MAXIMIZED = 2, + LIBDECOR_WINDOW_STATE_FULLSCREEN = 4, + LIBDECOR_WINDOW_STATE_TILED_LEFT = 8, + LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16, + LIBDECOR_WINDOW_STATE_TILED_TOP = 32, + LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64 }; enum libdecor_capabilities { - LIBDECOR_ACTION_MOVE = 1, - LIBDECOR_ACTION_RESIZE = 2, - LIBDECOR_ACTION_MINIMIZE = 4, - LIBDECOR_ACTION_FULLSCREEN = 8, - LIBDECOR_ACTION_CLOSE = 16 + LIBDECOR_ACTION_MOVE = 1, + LIBDECOR_ACTION_RESIZE = 2, + LIBDECOR_ACTION_MINIMIZE = 4, + LIBDECOR_ACTION_FULLSCREEN = 8, + LIBDECOR_ACTION_CLOSE = 16 }; struct libdecor_interface { - void (* error)(struct libdecor*,enum libdecor_error,const char*); - void (* reserved0)(void); - void (* reserved1)(void); - void (* reserved2)(void); - void (* reserved3)(void); - void (* reserved4)(void); - void (* reserved5)(void); - void (* reserved6)(void); - void (* reserved7)(void); - void (* reserved8)(void); - void (* reserved9)(void); + void (* error)(struct libdecor*,enum libdecor_error,const char*); + void (* reserved0)(void); + void (* reserved1)(void); + void (* reserved2)(void); + void (* reserved3)(void); + void (* reserved4)(void); + void (* reserved5)(void); + void (* reserved6)(void); + void (* reserved7)(void); + void (* reserved8)(void); + void (* reserved9)(void); }; struct libdecor_frame_interface { - void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*); - void (* close)(struct libdecor_frame*,void*); - void (* commit)(struct libdecor_frame*,void*); - void (* dismiss_popup)(struct libdecor_frame*,const char*,void*); - void (* reserved0)(void); - void (* reserved1)(void); - void (* reserved2)(void); - void (* reserved3)(void); - void (* reserved4)(void); - void (* reserved5)(void); - void (* reserved6)(void); - void (* reserved7)(void); - void (* reserved8)(void); - void (* reserved9)(void); + void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*); + void (* close)(struct libdecor_frame*,void*); + void (* commit)(struct libdecor_frame*,void*); + void (* dismiss_popup)(struct libdecor_frame*,const char*,void*); + void (* reserved0)(void); + void (* reserved1)(void); + void (* reserved2)(void); + void (* reserved3)(void); + void (* reserved4)(void); + void (* reserved5)(void); + void (* reserved6)(void); + void (* reserved7)(void); + void (* reserved8)(void); + void (* reserved9)(void); }; typedef struct libdecor* (* PFN_libdecor_new)(struct wl_display*,const struct libdecor_interface*); diff --git a/src/wl_window.c b/src/wl_window.c index 7e15a3d01..50f770e61 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2207,12 +2207,12 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) _glfw.wl.pointerFocus = NULL; if (window == _glfw.wl.keyboardFocus) - { - struct itimerspec timer = {0}; - timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); + { + struct itimerspec timer = {0}; + timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); _glfw.wl.keyboardFocus = NULL; - } + } if (window->wl.fractionalScale) wp_fractional_scale_v1_destroy(window->wl.fractionalScale); From ddbb8e0f2ccf20ada8e91f28b0b2c1f60c6699f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 15:28:36 +0200 Subject: [PATCH 032/112] Wayland: Fix fallback decoration cursor position If fallback decorations were in use, pointer motion over a decoration surface would cause glfwGetCursorPos to provide incorrect cursor positions. The cursor position is now only updated when the pointer is over the content area of the window, similar to libdecor and XDG decorations. --- README.md | 2 ++ src/wl_platform.h | 1 + src/wl_window.c | 20 +++++++++++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 456c75333..a3fd32b28 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) - [Wayland] Bugfix: Memory would leak if reading a data offer failed midway - [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736) + - [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over + fallback decorations - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_platform.h b/src/wl_platform.h index eb68f7e8f..a85a7c2ae 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -413,6 +413,7 @@ typedef struct _GLFWwindowWayland struct wl_buffer* buffer; _GLFWfallbackEdgeWayland top, left, right, bottom; struct wl_surface* focus; + wl_fixed_t pointerX, pointerY; } fallback; } _GLFWwindowWayland; diff --git a/src/wl_window.c b/src/wl_window.c index 50f770e61..677efd79b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1446,11 +1446,11 @@ static void pointerHandleMotion(void* userData, const double xpos = wl_fixed_to_double(sx); const double ypos = wl_fixed_to_double(sy); - window->wl.cursorPosX = xpos; - window->wl.cursorPosY = ypos; if (window->wl.hovered) { + window->wl.cursorPosX = xpos; + window->wl.cursorPosY = ypos; _glfw.wl.cursorPreviousName = NULL; _glfwInputCursorPos(window, xpos, ypos); return; @@ -1458,6 +1458,9 @@ static void pointerHandleMotion(void* userData, if (window->wl.fallback.decorations) { + window->wl.fallback.pointerX = sx; + window->wl.fallback.pointerY = sy; + const char* cursorName = "left_ptr"; if (window->resizable) @@ -1557,36 +1560,39 @@ static void pointerHandleButton(void* userData, if (window->wl.fallback.decorations) { + const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX); + const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY); + if (button == BTN_LEFT) { uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; if (window->wl.fallback.focus == window->wl.fallback.top.surface) { - if (window->wl.cursorPosY < GLFW_BORDER_SIZE) + if (ypos < 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) + if (ypos < 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) + if (ypos < 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) + if (xpos < GLFW_BORDER_SIZE) edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; - else if (window->wl.cursorPosX > window->wl.width + GLFW_BORDER_SIZE) + else if (xpos > window->wl.width + GLFW_BORDER_SIZE) edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT; else edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM; From 5190a30d8a96d76de172cb6595e4fd658ca8ada1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 15:43:32 +0200 Subject: [PATCH 033/112] Wayland: Move fallback decoration struct member The cursorPreviousName member was only used for the fallback decorations but was not grouped with other related members. --- src/wl_platform.h | 2 +- src/wl_window.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index a85a7c2ae..c3e456931 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -414,6 +414,7 @@ typedef struct _GLFWwindowWayland _GLFWfallbackEdgeWayland top, left, right, bottom; struct wl_surface* focus; wl_fixed_t pointerX, pointerY; + const char* cursorName; } fallback; } _GLFWwindowWayland; @@ -455,7 +456,6 @@ typedef struct _GLFWlibraryWayland struct wl_cursor_theme* cursorTheme; struct wl_cursor_theme* cursorThemeHiDPI; struct wl_surface* cursorSurface; - const char* cursorPreviousName; int cursorTimerfd; uint32_t serial; uint32_t pointerEnterSerial; diff --git a/src/wl_window.c b/src/wl_window.c index 677efd79b..b8a3e716f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1417,7 +1417,6 @@ static void pointerHandleLeave(void* userData, _glfw.wl.serial = serial; _glfw.wl.pointerFocus = NULL; - _glfw.wl.cursorPreviousName = NULL; if (window->wl.hovered) { @@ -1427,7 +1426,10 @@ static void pointerHandleLeave(void* userData, else { if (window->wl.fallback.decorations) + { window->wl.fallback.focus = NULL; + window->wl.fallback.cursorName = NULL; + } } } @@ -1451,7 +1453,6 @@ static void pointerHandleMotion(void* userData, { window->wl.cursorPosX = xpos; window->wl.cursorPosY = ypos; - _glfw.wl.cursorPreviousName = NULL; _glfwInputCursorPos(window, xpos, ypos); return; } @@ -1495,7 +1496,7 @@ static void pointerHandleMotion(void* userData, } } - if (_glfw.wl.cursorPreviousName != cursorName) + if (window->wl.fallback.cursorName != cursorName) { struct wl_surface* surface = _glfw.wl.cursorSurface; struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; @@ -1531,7 +1532,7 @@ static void pointerHandleMotion(void* userData, wl_surface_damage(surface, 0, 0, image->width, image->height); wl_surface_commit(surface); - _glfw.wl.cursorPreviousName = cursorName; + window->wl.fallback.cursorName = cursorName; } } } From 7523b0e6bdd84baa68d4de731a978581293aae0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 16:00:25 +0200 Subject: [PATCH 034/112] Wayland: Move fallback decoration pointer logic Decluttered the wl_pointer handlers by moving the bulk of fallback decoration related logic to separate functions. --- src/wl_window.c | 293 +++++++++++++++++++++++++----------------------- 1 file changed, 152 insertions(+), 141 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index b8a3e716f..99a8a0e28 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -275,6 +275,149 @@ static void destroyFallbackDecorations(_GLFWwindow* window) destroyFallbackEdge(&window->wl.fallback.bottom); } +static void updateFallbackDecorationCursor(_GLFWwindow* window, + wl_fixed_t sx, + wl_fixed_t sy) +{ + window->wl.fallback.pointerX = sx; + window->wl.fallback.pointerY = sy; + + const double xpos = wl_fixed_to_double(sx); + const double ypos = wl_fixed_to_double(sy); + const char* cursorName = "left_ptr"; + + if (window->resizable) + { + 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 (window->wl.fallback.cursorName != cursorName) + { + struct wl_surface* surface = _glfw.wl.cursorSurface; + struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; + int scale = 1; + + 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. + scale = 2; + theme = _glfw.wl.cursorThemeHiDPI; + } + + struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName); + if (!cursor) + return; + + // TODO: handle animated cursors too. + struct wl_cursor_image* image = cursor->images[0]; + if (!image) + return; + + 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); + + window->wl.fallback.cursorName = cursorName; + } +} + +static void handleFallbackDecorationButton(_GLFWwindow* window, + uint32_t serial, + uint32_t button) +{ + const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX); + const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY); + + if (button == BTN_LEFT) + { + uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; + + if (window->wl.fallback.focus == window->wl.fallback.top.surface) + { + if (ypos < 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 (ypos < 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 (ypos < 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 (xpos < GLFW_BORDER_SIZE) + edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; + else if (xpos > 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, + 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); + } + } +} + static void xdgDecorationHandleConfigure(void* userData, struct zxdg_toplevel_decoration_v1* decoration, uint32_t mode) @@ -1446,94 +1589,16 @@ static void pointerHandleMotion(void* userData, if (window->cursorMode == GLFW_CURSOR_DISABLED) return; - const double xpos = wl_fixed_to_double(sx); - const double ypos = wl_fixed_to_double(sy); - if (window->wl.hovered) { - window->wl.cursorPosX = xpos; - window->wl.cursorPosY = ypos; - _glfwInputCursorPos(window, xpos, ypos); - return; + window->wl.cursorPosX = wl_fixed_to_double(sx); + window->wl.cursorPosY = wl_fixed_to_double(sy); + _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); } - - if (window->wl.fallback.decorations) + else { - window->wl.fallback.pointerX = sx; - window->wl.fallback.pointerY = sy; - - const char* cursorName = "left_ptr"; - - if (window->resizable) - { - 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 (window->wl.fallback.cursorName != cursorName) - { - struct wl_surface* surface = _glfw.wl.cursorSurface; - struct wl_cursor_theme* theme = _glfw.wl.cursorTheme; - int scale = 1; - - 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. - scale = 2; - theme = _glfw.wl.cursorThemeHiDPI; - } - - struct wl_cursor* cursor = wl_cursor_theme_get_cursor(theme, cursorName); - if (!cursor) - return; - - // TODO: handle animated cursors too. - struct wl_cursor_image* image = cursor->images[0]; - if (!image) - return; - - 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); - - window->wl.fallback.cursorName = cursorName; - } + if (window->wl.fallback.decorations) + updateFallbackDecorationCursor(window, sx, sy); } } @@ -1556,65 +1621,11 @@ static void pointerHandleButton(void* userData, button - BTN_LEFT, state == WL_POINTER_BUTTON_STATE_PRESSED, _glfw.wl.xkb.modifiers); - return; } - - if (window->wl.fallback.decorations) + else { - const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX); - const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY); - - if (button == BTN_LEFT) - { - uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; - - if (window->wl.fallback.focus == window->wl.fallback.top.surface) - { - if (ypos < 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 (ypos < 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 (ypos < 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 (xpos < GLFW_BORDER_SIZE) - edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; - else if (xpos > 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, - 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.fallback.decorations) + handleFallbackDecorationButton(window, serial, button); } } From 645a35a38ed2cefd5a236db3eebc51f63065a4e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 16:04:40 +0200 Subject: [PATCH 035/112] Wayland: Cleanup --- src/wl_window.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 99a8a0e28..134ef6d1a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -401,10 +401,7 @@ static void handleFallbackDecorationButton(_GLFWwindow* window, } if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) - { - xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, - serial, edges); - } + xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, serial, edges); } else if (button == BTN_RIGHT) { From 161fb1b6f6adaf92a88a922bb2d974fb62e911d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Jul 2025 16:35:57 +0200 Subject: [PATCH 036/112] Wayland: Fix fallback decoration scroll events The fallback decorations would emit scroll events as if scrolling had occurred over the content area of the window. --- README.md | 1 + src/wl_window.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a3fd32b28..d1be31411 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736) - [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over fallback decorations + - [Wayland] Bugfix: Fallback decorations would report scroll events - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_window.c b/src/wl_window.c index 134ef6d1a..0a6a8543e 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1636,11 +1636,14 @@ static void pointerHandleAxis(void* userData, if (!window) return; - // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio - if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) - _glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0); - else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) - _glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0); + if (window->wl.hovered) + { + // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio + if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) + _glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0); + else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) + _glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0); + } } static const struct wl_pointer_listener pointerListener = From 768e81a0eb3ae411d108168fdff7cd3335f2a34a Mon Sep 17 00:00:00 2001 From: Jan Hendrik Farr Date: Fri, 31 May 2024 01:42:53 +0200 Subject: [PATCH 037/112] Wayland: Fix key repeat halting Key repeat shoud only be halted when the repeating key is released, not when another key is released. --- CONTRIBUTORS.md | 1 + README.md | 1 + src/wl_window.c | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 8fa1cb724..295a4c477 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -68,6 +68,7 @@ video tutorials. - Jan Ekström - Siavash Eliasi - er-azh + - Jan Hendrik Farr - Ahmad Fatoum - Nikita Fediuchin - Felipe Ferreira diff --git a/README.md b/README.md index d1be31411..cebdf0896 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over fallback decorations - [Wayland] Bugfix: Fallback decorations would report scroll events + - [Wayland] Bugfix: Keyboard repeat events halted when any key is released (#2568) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_window.c b/src/wl_window.c index 0a6a8543e..b33a2262f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1838,11 +1838,12 @@ static void keyboardHandleKey(void* userData, timer.it_value.tv_sec = _glfw.wl.keyRepeatDelay / 1000; timer.it_value.tv_nsec = (_glfw.wl.keyRepeatDelay % 1000) * 1000000; + timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); } + } else if (scancode == _glfw.wl.keyRepeatScancode) { + timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); } - timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); - _glfwInputKey(window, key, scancode, action, _glfw.wl.xkb.modifiers); if (action == GLFW_PRESS) From 0d2d85d19c16ae936fb6b076a1a9ccdd732e65c0 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Fri, 15 Aug 2025 11:27:59 +0200 Subject: [PATCH 038/112] Revert "Wayland: Keyboard leave event handler now processes key repeats" --- src/wl_window.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index b33a2262f..2b172c9c2 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1778,24 +1778,6 @@ static void keyboardHandleLeave(void* userData, if (!window) return; - // Handle any key repeats up to this point. We don't poll as this should be infrequent. - uint64_t repeats; - if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8) - { - if(_glfw.wl.keyboardFocus) - { - for (uint64_t i = 0; i < repeats; i++) - { - _glfwInputKey(_glfw.wl.keyboardFocus, - translateKey(_glfw.wl.keyRepeatScancode), - _glfw.wl.keyRepeatScancode, - GLFW_PRESS, - _glfw.wl.xkb.modifiers); - inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode); - } - } - } - struct itimerspec timer = {0}; timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); From bfa1c424e56093bc4a08184ec68543e45b468374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Aug 2025 21:19:13 +0200 Subject: [PATCH 039/112] Wayland: Fix fallback decoration menu placement The fallback decorations would place the menu at the wrong position, by not translating the last decoration surface position into toplevel surface coordinates. This also limits the menu to the caption area of the top decoration surface, similar to how other toolkits work. --- README.md | 1 + src/wl_window.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cebdf0896..6efa1ae70 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ information on what to include when reporting a bug. fallback decorations - [Wayland] Bugfix: Fallback decorations would report scroll events - [Wayland] Bugfix: Keyboard repeat events halted when any key is released (#2568) + - [Wayland] Bugfix: Fallback decorations would show menu at wrong position - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_window.c b/src/wl_window.c index 2b172c9c2..b9aa405d1 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -405,13 +405,19 @@ static void handleFallbackDecorationButton(_GLFWwindow* window, } 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) + return; + + if (window->wl.fallback.focus != window->wl.fallback.top.surface) + return; + + if (ypos < GLFW_BORDER_SIZE) + return; + + xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, + _glfw.wl.seat, serial, + xpos, + ypos - GLFW_CAPTION_HEIGHT - GLFW_BORDER_SIZE); } } From 3cf9f6726d1062c219d861755768ec5a2a238ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Aug 2025 16:17:55 +0200 Subject: [PATCH 040/112] Wayland: Fix fallback decoration cursor updating When a click through to the fallback decorations caused the end of a modal like the window menu, the cursor shape would not be updated until the next time the cursor moved. This commit adds an update of the cursor for the pointer enter event for fallback decoration surfaces, in addition to the updates at pointer motion events. --- README.md | 2 ++ src/wl_window.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 6efa1ae70..f7c3b07d3 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Fallback decorations would report scroll events - [Wayland] Bugfix: Keyboard repeat events halted when any key is released (#2568) - [Wayland] Bugfix: Fallback decorations would show menu at wrong position + - [Wayland] Bugfix: The cursor was not updated when clicking through from + a modal to a fallback decoration - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_window.c b/src/wl_window.c index b9aa405d1..ed767055d 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1542,7 +1542,10 @@ static void pointerHandleEnter(void* userData, else { if (window->wl.fallback.decorations) + { window->wl.fallback.focus = surface; + updateFallbackDecorationCursor(window, sx, sy); + } } } From 7ef6efeb662e0833645e4b03b910e054fc7d8a85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Aug 2025 21:38:37 +0200 Subject: [PATCH 041/112] Wayland: Fix cursor position after a modal If a modal surface like the window menu was active, clicking on the GLFW window content area to close it would correctly emit the cursor enter event but would not propagate the cursor position from the event. --- README.md | 2 ++ src/wl_window.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index f7c3b07d3..c0a473d41 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Fallback decorations would show menu at wrong position - [Wayland] Bugfix: The cursor was not updated when clicking through from a modal to a fallback decoration + - [Wayland] Bugfix: The cursor position was not updated when clicking through + from a modal to the content area - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [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_window.c b/src/wl_window.c index ed767055d..4220d17e0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1538,6 +1538,13 @@ static void pointerHandleEnter(void* userData, window->wl.hovered = GLFW_TRUE; _glfwSetCursorWayland(window, window->wl.currentCursor); _glfwInputCursorEnter(window, GLFW_TRUE); + + if (window->cursorMode != GLFW_CURSOR_DISABLED) + { + window->wl.cursorPosX = wl_fixed_to_double(sx); + window->wl.cursorPosY = wl_fixed_to_double(sy); + _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); + } } else { From acb92944d4e97e6efa36057927c9fcf114710226 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Tue, 19 Aug 2025 11:30:52 +0200 Subject: [PATCH 042/112] Revert readme for "Wayland: Keyboard leave event handler now processes key repeats" --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index c0a473d41..6eb6b9bd1 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,6 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727) - [Wayland] Bugfix: Reset key repeat timer when window destroyed (#2741,#2727) - [Wayland] Bugfix: Memory would leak if reading a data offer failed midway - - [Wayland] Bugfix: Keyboard leave event handler now processes key repeats (#2736) - [Wayland] Bugfix: Retrieved cursor position would be incorrect when hovering over fallback decorations - [Wayland] Bugfix: Fallback decorations would report scroll events From 63a7e8b7f82497b0459acba5c1ce7f39aa2bc0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Aug 2025 21:06:50 +0200 Subject: [PATCH 043/112] Add and update Wayland-specific notes in docs Fixes #2746 --- CONTRIBUTORS.md | 1 + docs/monitor.md | 4 ++++ docs/window.md | 12 ++++++++++++ include/GLFW/glfw3.h | 45 ++++++++++++++++++++++++-------------------- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 295a4c477..d8eb7aee0 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -55,6 +55,7 @@ video tutorials. - Jason Daly - danhambleton - Jarrod Davis + - decce - Olivier Delannoy - Paul R. Deppe - Michael Dickens diff --git a/docs/monitor.md b/docs/monitor.md index 12d98541a..df5fda9ae 100644 --- a/docs/monitor.md +++ b/docs/monitor.md @@ -255,3 +255,7 @@ 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. +@note @wayland An application cannot read or modify the monitor gamma ramp. The +@ref glfwGetGammaRamp, @ref glfwSetGammaRamp and @ref glfwSetGamma functions +emit @ref GLFW_FEATURE_UNAVAILABLE. + diff --git a/docs/window.md b/docs/window.md index 371baa562..dd6d8a2aa 100644 --- a/docs/window.md +++ b/docs/window.md @@ -893,6 +893,12 @@ int xpos, ypos; glfwGetWindowPos(window, &xpos, &ypos); ``` +@note @wayland An applications cannot know the positions of its windows or +whether one has been moved. The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y +window hints are ignored. The @ref glfwGetWindowPos and @ref glfwSetWindowPos +functions emit @ref GLFW_FEATURE_UNAVAILABLE. The window position callback will +not be called. + ### Window title {#window_title} @@ -1038,6 +1044,12 @@ You can also get the current iconification state with @ref glfwGetWindowAttrib. int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); ``` +@note @wayland An application cannot know if any of its windows have been +iconified or restore one from iconification. The @ref glfwRestoreWindow +function can only restore windows from maximization and the iconify callback +will not be called. The [GLFW_ICONIFIED](@ref GLFW_ICONIFIED_attrib) attribute +will be false. The @ref glfwIconifyWindow function works normally. + ### Window maximization {#window_maximize} diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 79b062884..b0ce7f660 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2915,8 +2915,8 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE, * @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Gamma handling is a privileged protocol, this function - * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. + * @remark @wayland Monitor gamma is a privileged protocol, so this function + * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. * @@ -2939,8 +2939,8 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Gamma handling is a privileged protocol, this function - * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while + * @remark @wayland Monitor gamma is a privileged protocol, so this function + * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while * returning `NULL`. * * @pointer_lifetime The returned structure and its arrays are allocated and @@ -2983,8 +2983,8 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); * * @remark @win32 The gamma ramp size must be 256. * - * @remark @wayland Gamma handling is a privileged protocol, this function - * will thus never be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. + * @remark @wayland Monitor gamma is a privileged protocol, so this function + * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * * @pointer_lifetime The specified gamma ramp is copied before this function * returns. @@ -3430,8 +3430,8 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland There is no way for an application to retrieve the global - * position of its windows. This function will emit @ref + * @remark @wayland Window positions are not currently part of any common + * Wayland protocol, so this function cannot be implemented and will emit @ref * GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -3464,8 +3464,8 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland There is no way for an application to set the global - * position of its windows. This function will emit @ref + * @remark @wayland Window positions are not currently part of any common + * Wayland protocol, so this function cannot be implemented and will emit @ref * GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -3807,10 +3807,6 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t - * be able to restore it. This is a design decision of the xdg-shell - * protocol. - * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_iconify @@ -3838,6 +3834,10 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * + * @remark @wayland Restoring a window from maximization is not currently part + * of any common Wayland protocol, so this function can only restore windows + * from maximization. + * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_iconify @@ -4058,8 +4058,8 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); * affected by any resizing or mode switching, although you may need to update * your viewport if the framebuffer size has changed. * - * @remark @wayland The desired window position is ignored, as there is no way - * for an application to set this property. + * @remark @wayland Window positions are not currently part of any common + * Wayland protocol. The window position arguments are ignored. * * @thread_safety This function must only be called from the main thread. * @@ -4096,8 +4096,9 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int * errors. However, this function should not fail as long as it is passed * valid arguments and the library has been [initialized](@ref intro_init). * - * @remark @wayland The Wayland protocol provides no way to check whether a - * window is iconfied, so @ref GLFW_ICONIFIED always returns `GLFW_FALSE`. + * @remark @wayland Checking whether a window is iconified is not currently + * part of any common Wayland protocol, so the @ref GLFW_ICONIFIED attribute + * cannot be implemented and is always `GLFW_FALSE`. * * @thread_safety This function must only be called from the main thread. * @@ -4219,8 +4220,8 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @wayland This callback will never be called, as there is no way for - * an application to know its global position. + * @remark @wayland This callback will not be called. The Wayland protocol + * provides no way to be notified of when a window is moved. * * @thread_safety This function must only be called from the main thread. * @@ -4395,6 +4396,10 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * + * @remark @wayland This callback will not be called. The Wayland protocol + * provides no way to be notified of when a window is iconified, and no way to + * check whether a window is currently iconified. + * * @thread_safety This function must only be called from the main thread. * * @sa @ref window_iconify From 5c87937e444bef5b796f6f877bd9bcf549e3ef9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Aug 2025 19:07:33 +0200 Subject: [PATCH 044/112] Update README --- README.md | 129 +++++++++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 6eb6b9bd1..5148467a7 100644 --- a/README.md +++ b/README.md @@ -9,34 +9,28 @@ GLFW is an 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. -GLFW natively supports Windows, macOS and Linux and other Unix-like systems. On -Linux both Wayland and X11 are supported. +GLFW is written primarily in C99, with parts of macOS support being written in +Objective-C. + +GLFW supports Windows, macOS and Linux, and also works on many other Unix-like +systems. On Linux both Wayland and X11 are supported. 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. 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 and macOS binaries. There are [release +tags](https://github.com/glfw/glfw/releases) with source and binary archives +attached for every version since 3.0. The [documentation](https://www.glfw.org/docs/latest/) is available online and is -included in all source and binary archives. See the [release -notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and -deprecations in the latest release. For more details see the [version -history](https://www.glfw.org/changelog.html). - -The `master` branch is the stable integration branch and _should_ always compile -and run on all supported platforms, although details of newly added features may -change until they have been included in a release. New features and many bug -fixes live in [other branches](https://github.com/glfw/glfw/branches/all) until -they are stable enough to merge. - -If you are new to GLFW, you may find the -[tutorial](https://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful. If -you have used GLFW 2 in the past, there is a [transition -guide](https://www.glfw.org/docs/latest/moving.html) for moving to the GLFW -3 API. +also included in source and binary archives, except those generated +automatically by Github. The documentation contains guides, a tutorial and the +API reference. The [release +notes](https://www.glfw.org/docs/latest/news.html) list the new features, +caveats and deprecations in the latest release. The [version +history](https://www.glfw.org/changelog.html) lists every user-visible change +for every release. GLFW exists because of the contributions of [many people](CONTRIBUTORS.md) around the world, whether by reporting bugs, providing community support, adding @@ -44,57 +38,37 @@ features, reviewing or testing code, debugging, proofreading docs, suggesting features or fixing bugs. -## Compiling GLFW - -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++ (2013 and later) 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 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. - - -## Using GLFW - -See the [documentation](https://www.glfw.org/docs/latest/) for tutorials, guides -and the API reference. - - -## Contributing to GLFW - -See the [contribution -guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for -more information. - - ## System requirements -GLFW supports Windows 7 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. +GLFW supports Windows 7 and later and macOS 10.11 and later. On GNOME Wayland, +window decorations will be very basic unless the +[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor) package is +installed. Linux and other Unix-like systems running X11 are supported even +without a desktop environment or modern extensions, although some features +require a clipboard manager or a modern window manager. See the [compatibility guide](https://www.glfw.org/docs/latest/compat.html) -in the documentation for more information. +for more detailed information. -## Dependencies +## Compiling GLFW -GLFW itself needs only CMake 3.16 or later and the headers and libraries for your -OS and window system. +GLFW supports compilation with Visual C++ (2013 and later), GCC and Clang. Both +Clang-CL and MinGW-w64 are supported. Other C99 compilers will likely also +work, but this is not regularly tested. + +There are [pre-compiled binaries](https://www.glfw.org/download.html) +available for Windows and macOS. + +GLFW itself needs only CMake and the headers and libraries for your operating +system and window system. No other SDKs are required. + +See the [compilation guide](https://www.glfw.org/docs/latest/compile.html) for +more information about compiling GLFW and the exact dependencies required for +each window system. The examples and test programs depend on a number of tiny libraries. These are -located in the `deps/` directory. +bundled in the `deps/` directory. The repository has no submodules. - [getopt\_port](https://github.com/kimgr/getopt_port/) for examples with command-line options @@ -107,8 +81,33 @@ located in the `deps/` directory. - [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI - [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk -The documentation is generated with [Doxygen](https://doxygen.org/) if CMake can -find that tool. +The documentation is generated with [Doxygen](https://doxygen.org/) when the +library is built, provided CMake could find a sufficiently new version of it +during configuration. + + +## Using GLFW + +See the [HTML documentation](https://www.glfw.org/docs/latest/) for a tutorial, +guides and the API reference. + + +## Contributing to GLFW + +See the [contribution +guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for +more information. + +The `master` branch is the stable integration branch and _should_ always compile +and run on all supported platforms. Details of a newly added feature, +including the public API, may change until it has been included in a release. + +The `latest` branch is equivalent to the [highest numbered](https://semver.org/) +release, although it may not always point to the same commit as the tag for that +release. + +The `ci` branch is used to trigger continuous integration jobs for code under +testing and should never be relied on for any purpose. ## Reporting bugs From 04a67c826718c7099c532bd90aa9d2ac97958d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 28 Aug 2025 18:56:48 +0200 Subject: [PATCH 045/112] Fix X11 clipboard compatibility description --- docs/compat.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/compat.md b/docs/compat.md index 5072d5c11..a97192b3f 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -50,10 +50,11 @@ 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][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 keep the +clipboard string availble for the user after the libary has been terminated. If +there is no running clipboard manager and the clipboard contents has been set +with @ref glfwSetClipboardString, the clipboard will be emptied when the library +is terminated. [clipboardManager]: https://www.freedesktop.org/wiki/ClipboardManager/ From c9b129753aa3a002de90c8458e4c8121a2fe6d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Aug 2025 21:36:19 +0200 Subject: [PATCH 046/112] Update Doxygen version handling --- docs/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 50522173a..4cf863653 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,4 +1,8 @@ +# Because of bugs and limitations in its Markdown support, only fairly recent +# versions of Doxygen can produce acceptable output +set(MINIMUM_DOXYGEN_VERSION 1.9.8) + # 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 @@ -32,10 +36,10 @@ foreach(file IN LISTS source_files) endforeach() set(DOXYGEN_SKIP_DOT TRUE) -find_package(Doxygen) +find_package(Doxygen ${MINIMUM_DOXYGEN_VERSION} QUIET) -if (NOT DOXYGEN_FOUND OR DOXYGEN_VERSION VERSION_LESS "1.9.8") - message(STATUS "Documentation generation requires Doxygen 1.9.8 or later") +if (NOT DOXYGEN_FOUND) + message(STATUS "Documentation generation requires Doxygen ${MINIMUM_DOXYGEN_VERSION} or later") else() configure_file(Doxyfile.in Doxyfile @ONLY) add_custom_command(OUTPUT "html/index.html" From 1fdd39cf3e5badfd61d051d686b21c1963bbb045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Aug 2025 21:36:59 +0200 Subject: [PATCH 047/112] Fix documentation target dependency Related to #2704 --- CONTRIBUTORS.md | 1 + docs/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d8eb7aee0..22ef76d0a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -23,6 +23,7 @@ video tutorials. - Denis Bernard - BiBi - Doug Binks + - bitb4ker - blanco - Waris Boonyasiriwat - Kyle Brenneman diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 4cf863653..629c16441 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -50,7 +50,7 @@ else() COMMENT "Generating HTML documentation" VERBATIM) - add_custom_target(docs ALL SOURCES "html/index.html") + add_custom_target(docs ALL DEPENDS "html/index.html") set_target_properties(docs PROPERTIES FOLDER "GLFW3") if (GLFW_INSTALL) From f8582d26d0c88c67ddee5606dcf688107e875d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 21 Aug 2025 23:51:45 +0200 Subject: [PATCH 048/112] Add Markdown files as sources to IDE docs target --- docs/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 629c16441..ffa7768ea 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -50,7 +50,7 @@ else() COMMENT "Generating HTML documentation" VERBATIM) - add_custom_target(docs ALL DEPENDS "html/index.html") + add_custom_target(docs ALL SOURCES ${source_files} DEPENDS "html/index.html") set_target_properties(docs PROPERTIES FOLDER "GLFW3") if (GLFW_INSTALL) From bfcb98fb6cfcee008207f9252bd5c76a98e76e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Mar 2024 19:59:04 +0100 Subject: [PATCH 049/112] Replace some Doxygen aliases with Markdown --- docs/Doxyfile.in | 8 +-- docs/intro.md | 2 +- docs/monitor.md | 4 +- docs/vulkan.md | 6 +- docs/window.md | 10 +-- include/GLFW/glfw3.h | 162 +++++++++++++++++++++---------------------- 6 files changed, 93 insertions(+), 99 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 067619c7d..27c4b3f67 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -278,13 +278,7 @@ ALIASES = "thread_safety=@par Thread safety^^" \ "analysis=@par Analysis^^" \ "reentrancy=@par Reentrancy^^" \ "errors=@par Errors^^" \ - "callback_signature=@par Callback signature^^" \ - "glfw3=__GLFW 3:__" \ - "x11=__X11:__" \ - "wayland=__Wayland:__" \ - "win32=__Windows:__" \ - "macos=__macOS:__" \ - "linux=__Linux:__" + "callback_signature=@par Callback signature^^" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For diff --git a/docs/intro.md b/docs/intro.md index f2060c330..e09989e03 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -63,7 +63,7 @@ before the application exits. Modern systems are very good at freeing resources allocated by programs that exit, but GLFW sometimes has to change global system settings and these might not be restored without termination. -@macos When the library is initialized the main menu and dock icon are created. +__macOS:__ When the library is initialized the main menu and dock icon are created. These are not desirable for a command-line only program. The creation of the main menu and dock icon can be disabled with the @ref GLFW_COCOA_MENUBAR init hint. diff --git a/docs/monitor.md b/docs/monitor.md index df5fda9ae..8e01a8f25 100644 --- a/docs/monitor.md +++ b/docs/monitor.md @@ -255,7 +255,7 @@ 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. -@note @wayland An application cannot read or modify the monitor gamma ramp. The -@ref glfwGetGammaRamp, @ref glfwSetGammaRamp and @ref glfwSetGamma functions +@note __Wayland:__ An application cannot read or modify the monitor gamma ramp. +The @ref glfwGetGammaRamp, @ref glfwSetGammaRamp and @ref glfwSetGamma functions emit @ref GLFW_FEATURE_UNAVAILABLE. diff --git a/docs/vulkan.md b/docs/vulkan.md index cb67302fb..48fa79fd1 100644 --- a/docs/vulkan.md +++ b/docs/vulkan.md @@ -35,7 +35,7 @@ By default, GLFW will load the Vulkan loader dynamically at runtime via its stan `vulkan-1.dll` on Windows, `libvulkan.so.1` on Linux and other Unix-like systems and `libvulkan.1.dylib` on macOS. -@macos GLFW will also look up and search the `Frameworks` subdirectory of your +__macOS:__ GLFW will also look up and search the `Frameworks` subdirectory of your application bundle. If your code is using a Vulkan loader with a different name or in a non-standard location @@ -47,7 +47,7 @@ entry point retrieval. This prevents GLFW from dynamically loading the Vulkan l glfwInitVulkanLoader(vkGetInstanceProcAddr); ``` -@macos To make your application be redistributable you will need to set up the application +__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 [SDK documentation for macOS](https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html). @@ -186,7 +186,7 @@ check whether any extensions you wish to enable are already in the returned array, as it is an error to specify an extension more than once in the `VkInstanceCreateInfo` struct. -@macos MoltenVK is (as of July 2022) not yet a fully conformant implementation +__macOS:__ MoltenVK is (as of July 2022) not yet a fully conformant implementation of Vulkan. As of Vulkan SDK 1.3.216.0, this means you must also enable the `VK_KHR_portability_enumeration` instance extension and set the `VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR` bit in the instance creation diff --git a/docs/window.md b/docs/window.md index dd6d8a2aa..2140f0975 100644 --- a/docs/window.md +++ b/docs/window.md @@ -363,10 +363,10 @@ which API was used to create the current context may fail if you change this hint. This can be resolved by having it load functions via @ref glfwGetProcAddress. -@note @wayland The EGL API _is_ the native context creation API, so this hint +@note __Wayland:__ The EGL API _is_ the native context creation API, so this hint will have no effect. -@note @x11 On some Linux systems, creating contexts via both the native and EGL +@note __X11:__ On some Linux systems, creating contexts via both the native and EGL APIs in a single process will cause the application to segfault. Stick to one API or the other on Linux for now. @@ -400,7 +400,7 @@ requested. Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested, and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x. -@note @macos The OS only supports core profile contexts for OpenGL versions 3.2 +@note __macOS:__ The OS only supports core profile contexts for OpenGL versions 3.2 and later. Before creating an OpenGL context of version 3.2 or later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all on macOS. @@ -893,7 +893,7 @@ int xpos, ypos; glfwGetWindowPos(window, &xpos, &ypos); ``` -@note @wayland An applications cannot know the positions of its windows or +@note __Wayland:__ An applications cannot know the positions of its windows or whether one has been moved. The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints are ignored. The @ref glfwGetWindowPos and @ref glfwSetWindowPos functions emit @ref GLFW_FEATURE_UNAVAILABLE. The window position callback will @@ -1044,7 +1044,7 @@ You can also get the current iconification state with @ref glfwGetWindowAttrib. int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); ``` -@note @wayland An application cannot know if any of its windows have been +@note __Wayland:__ An application cannot know if any of its windows have been iconified or restore one from iconification. The @ref glfwRestoreWindow function can only restore windows from maximization and the iconify callback will not be called. The [GLFW_ICONIFIED](@ref GLFW_ICONIFIED_attrib) attribute diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index b0ce7f660..3ce1c0191 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1228,13 +1228,13 @@ extern "C" { * The top-left to bottom-right diagonal resize/move shape. This is usually * a diagonal double-headed arrow. * - * @note @macos This shape is provided by a private system API and may fail + * @note __macOS:__ This shape is provided by a private system API and may fail * with @ref GLFW_CURSOR_UNAVAILABLE in the future. * - * @note @wayland This shape is provided by a newer standard not supported by + * @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 + * @note __X11:__ This shape is provided by a newer standard not supported by all * cursor themes. */ #define GLFW_RESIZE_NWSE_CURSOR 0x00036007 @@ -1243,13 +1243,13 @@ extern "C" { * The top-right to bottom-left diagonal resize/move shape. This is usually * a diagonal double-headed arrow. * - * @note @macos This shape is provided by a private system API and may fail + * @note __macOS:__ This shape is provided by a private system API and may fail * with @ref GLFW_CURSOR_UNAVAILABLE in the future. * - * @note @wayland This shape is provided by a newer standard not supported by + * @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 + * @note __X11:__ This shape is provided by a newer standard not supported by all * cursor themes. */ #define GLFW_RESIZE_NESW_CURSOR 0x00036008 @@ -1264,10 +1264,10 @@ extern "C" { * The operation-not-allowed shape. This is usually a circle with a diagonal * line through it. * - * @note @wayland This shape is provided by a newer standard not supported by + * @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 + * @note __X11:__ This shape is provided by a newer standard not supported by all * cursor themes. */ #define GLFW_NOT_ALLOWED_CURSOR 0x0003600A @@ -1629,7 +1629,7 @@ typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos); * @sa @ref glfwSetWindowSizeCallback * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -1649,7 +1649,7 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height); * @sa @ref glfwSetWindowCloseCallback * * @since Added in version 2.5. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -1669,7 +1669,7 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow* window); * @sa @ref glfwSetWindowRefreshCallback * * @since Added in version 2.5. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -1800,7 +1800,7 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, flo * @sa @ref glfwSetMouseButtonCallback * * @since Added in version 1.0. - * @glfw3 Added window handle and modifier mask parameters. + * __GLFW 3:__ Added window handle and modifier mask parameters. * * @ingroup input */ @@ -1891,7 +1891,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffse * @sa @ref glfwSetKeyCallback * * @since Added in version 1.0. - * @glfw3 Added window handle, scancode and modifier mask parameters. + * __GLFW 3:__ Added window handle, scancode and modifier mask parameters. * * @ingroup input */ @@ -1912,7 +1912,7 @@ typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int actio * @sa @ref glfwSetCharCallback * * @since Added in version 2.4. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup input */ @@ -2020,7 +2020,7 @@ typedef void (* GLFWjoystickfun)(int jid, int event); * @sa @ref glfwGetVideoModes * * @since Added in version 1.0. - * @glfw3 Added refresh rate member. + * __GLFW 3:__ Added refresh rate member. * * @ingroup monitor */ @@ -2083,7 +2083,7 @@ typedef struct GLFWgammaramp * @sa @ref window_icon * * @since Added in version 2.1. - * @glfw3 Removed format and bytes-per-pixel members. + * __GLFW 3:__ Removed format and bytes-per-pixel members. * * @ingroup window */ @@ -2183,12 +2183,12 @@ typedef struct GLFWallocator * @errors Possible errors include @ref GLFW_PLATFORM_UNAVAILABLE and @ref * GLFW_PLATFORM_ERROR. * - * @remark @macos This function will change the current directory of the + * @remark __macOS:__ This function will change the current directory of the * application to the `Contents/Resources` subdirectory of the application's * bundle, if present. This can be disabled with the @ref * GLFW_COCOA_CHDIR_RESOURCES init hint. * - * @remark @macos This function will create the main menu and dock icon for the + * @remark __macOS:__ This function will create the main menu and dock icon for the * application. If GLFW finds a `MainMenu.nib` it is loaded and assumed to * contain a menu bar. Otherwise a minimal menu bar is created manually with * common commands like Hide, Quit and About. The About entry opens a minimal @@ -2203,7 +2203,7 @@ 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 + * @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. * @@ -2679,7 +2679,7 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @win32 On Windows 8 and earlier the physical size is calculated from + * @remark __Win32:__ On Windows 8 and earlier the physical size is calculated from * the current resolution and system DPI instead of querying the monitor EDID data. * * @thread_safety This function must only be called from the main thread. @@ -2713,7 +2713,7 @@ 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 + * @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. @@ -2861,7 +2861,7 @@ GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback); * @sa @ref glfwGetVideoMode * * @since Added in version 1.0. - * @glfw3 Changed to return an array of modes for a specific monitor. + * __GLFW 3:__ Changed to return an array of modes for a specific monitor. * * @ingroup monitor */ @@ -2915,7 +2915,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_INVALID_VALUE, * @ref GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Monitor gamma is a privileged protocol, so this function + * @remark __Wayland:__ Monitor gamma is a privileged protocol, so this function * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -2939,7 +2939,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref GLFW_PLATFORM_ERROR * and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Monitor gamma is a privileged protocol, so this function + * @remark __Wayland:__ Monitor gamma is a privileged protocol, so this function * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE while * returning `NULL`. * @@ -2981,9 +2981,9 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); * @remark The size of the specified gamma ramp should match the size of the * current ramp for that monitor. * - * @remark @win32 The gamma ramp size must be 256. + * @remark __Win32:__ The gamma ramp size must be 256. * - * @remark @wayland Monitor gamma is a privileged protocol, so this function + * @remark __Wayland:__ Monitor gamma is a privileged protocol, so this function * cannot be implemented and emits @ref GLFW_FEATURE_UNAVAILABLE. * * @pointer_lifetime The specified gamma ramp is copied before this function @@ -3159,32 +3159,32 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * 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 + * @remark __Win32:__ Window creation will fail if the Microsoft GDI software * OpenGL implementation is the only one available. * - * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it + * @remark __Win32:__ If the executable has an icon resource named `GLFW_ICON,` it * will be set as the initial icon for the window. If no such icon is present, * the `IDI_APPLICATION` icon will be used instead. To set a different icon, * see @ref glfwSetWindowIcon. * - * @remark @win32 The context to share resources with must not be current on + * @remark __Win32:__ The context to share resources with must not be current on * any other thread. * - * @remark @macos The OS only supports core profile contexts for OpenGL + * @remark __macOS:__ The OS only supports core profile contexts for OpenGL * versions 3.2 and later. Before creating an OpenGL context of version 3.2 or * later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) * hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all * on macOS. * - * @remark @macos The GLFW window has no icon, as it is not a document + * @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][bundle-guide] in the Mac Developer Library. * * [bundle-guide]: https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/ * - * @remark @macos 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 @@ -3195,11 +3195,11 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * [hidpi-guide]: https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html * - * @remark @macos When activating frame autosaving with + * @remark __macOS:__ When activating frame autosaving with * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified * window size and position may be overridden by previously saved values. * - * @remark @wayland GLFW uses [libdecor][] where available to create its window + * @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 @@ -3208,15 +3208,15 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * [libdecor]: https://gitlab.freedesktop.org/libdecor/libdecor * - * @remark @x11 Some window managers will not respect the placement of + * @remark __X11:__ Some window managers will not respect the placement of * initially hidden windows. * - * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for + * @remark __X11:__ Due to the asynchronous nature of X11, it may take a moment for * a window to reach its requested state. This means you may not be able to * query the final size, position or other attributes directly after window * creation. * - * @remark @x11 The class part of the `WM_CLASS` window property will by + * @remark __X11:__ The class part of the `WM_CLASS` window property will by * default be set to the window title passed to this function. The instance * part will use the contents of the `RESOURCE_NAME` environment variable, if * present and not empty, or fall back to the window title. Set the @@ -3349,7 +3349,7 @@ GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @macos The window title will not be updated until the next time you + * @remark __macOS:__ The window title will not be updated until the next time you * process events. * * @thread_safety This function must only be called from the main thread. @@ -3358,7 +3358,7 @@ GLFWAPI const char* glfwGetWindowTitle(GLFWwindow* window); * @sa @ref glfwGetWindowTitle * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3392,14 +3392,14 @@ GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); * @pointer_lifetime The specified image data is copied before this function * returns. * - * @remark @macos Regular windows do not have icons on macOS. This function + * @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][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 + * @remark __Wayland:__ There is no existing protocol to change an icon, the * window will thus inherit the one defined in the application's desktop file. * This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * @@ -3430,7 +3430,7 @@ GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* i * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Window positions are not currently part of any common + * @remark __Wayland:__ Window positions are not currently part of any common * Wayland protocol, so this function cannot be implemented and will emit @ref * GLFW_FEATURE_UNAVAILABLE. * @@ -3464,7 +3464,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland Window positions are not currently part of any common + * @remark __Wayland:__ Window positions are not currently part of any common * Wayland protocol, so this function cannot be implemented and will emit @ref * GLFW_FEATURE_UNAVAILABLE. * @@ -3474,7 +3474,7 @@ GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); * @sa @ref glfwGetWindowPos * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3504,7 +3504,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); * @sa @ref glfwSetWindowSize * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3539,7 +3539,7 @@ GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); * @remark If you set size limits and an aspect ratio that conflict, the * results are undefined. * - * @remark @wayland The size limits will not be applied until the window is + * @remark __Wayland:__ The size limits will not be applied until the window is * actually resized, either by the user or by the compositor. * * @thread_safety This function must only be called from the main thread. @@ -3582,7 +3582,7 @@ GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minhe * @remark If you set size limits and an aspect ratio that conflict, the * results are undefined. * - * @remark @wayland The aspect ratio will not be applied until the window is + * @remark __Wayland:__ The aspect ratio will not be applied until the window is * actually resized, either by the user or by the compositor. * * @thread_safety This function must only be called from the main thread. @@ -3628,7 +3628,7 @@ GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom); * @sa @ref glfwSetWindowMonitor * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3778,7 +3778,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland There is no way to set an opacity factor for a window. + * @remark __Wayland:__ There is no way to set an opacity factor for a window. * This function will emit @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -3814,7 +3814,7 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity); * @sa @ref glfwMaximizeWindow * * @since Added in version 2.1. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3834,9 +3834,9 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland Restoring a window from maximization is not currently part - * of any common Wayland protocol, so this function can only restore windows - * from maximization. + * @remark __Wayland:__ Restoring a window from maximization is not currently + * part of any common Wayland protocol, so this function can only restore + * windows from maximization. * * @thread_safety This function must only be called from the main thread. * @@ -3845,7 +3845,7 @@ GLFWAPI void glfwIconifyWindow(GLFWwindow* window); * @sa @ref glfwMaximizeWindow * * @since Added in version 2.1. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -3892,7 +3892,7 @@ GLFWAPI void glfwMaximizeWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland Because Wayland wants every frame of the desktop to be + * @remark __Wayland:__ Because Wayland wants every frame of the desktop to be * complete, this function does not immediately make the window visible. * Instead it will become visible the next time the window framebuffer is * updated after this call. @@ -3955,7 +3955,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland The compositor will likely ignore focus requests unless + * @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. @@ -3983,7 +3983,7 @@ GLFWAPI void glfwFocusWindow(GLFWwindow* window); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @macos Attention is requested to the application as a whole, not the + * @remark __macOS:__ Attention is requested to the application as a whole, not the * specific window. * * @thread_safety This function must only be called from the main thread. @@ -4058,7 +4058,7 @@ GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); * affected by any resizing or mode switching, although you may need to update * your viewport if the framebuffer size has changed. * - * @remark @wayland Window positions are not currently part of any common + * @remark __Wayland:__ Window positions are not currently part of any common * Wayland protocol. The window position arguments are ignored. * * @thread_safety This function must only be called from the main thread. @@ -4096,7 +4096,7 @@ GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int * errors. However, this function should not fail as long as it is passed * valid arguments and the library has been [initialized](@ref intro_init). * - * @remark @wayland Checking whether a window is iconified is not currently + * @remark __Wayland:__ Checking whether a window is iconified is not currently * part of any common Wayland protocol, so the @ref GLFW_ICONIFIED attribute * cannot be implemented and is always `GLFW_FALSE`. * @@ -4140,7 +4140,7 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); * @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 + * @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. @@ -4220,7 +4220,7 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @wayland This callback will not be called. The Wayland protocol + * @remark __Wayland:__ This callback will not be called. The Wayland protocol * provides no way to be notified of when a window is moved. * * @thread_safety This function must only be called from the main thread. @@ -4259,7 +4259,7 @@ GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindow * @sa @ref window_size * * @since Added in version 1.0. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup window */ @@ -4291,7 +4291,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @macos Selecting Quit from the application menu will trigger the + * @remark __macOS:__ Selecting Quit from the application menu will trigger the * close callback for all windows. * * @thread_safety This function must only be called from the main thread. @@ -4299,7 +4299,7 @@ GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwind * @sa @ref window_close * * @since Added in version 2.5. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup window */ @@ -4335,7 +4335,7 @@ GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwi * @sa @ref window_refresh * * @since Added in version 2.5. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup window */ @@ -4396,7 +4396,7 @@ GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwi * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. * - * @remark @wayland This callback will not be called. The Wayland protocol + * @remark __Wayland:__ This callback will not be called. The Wayland protocol * provides no way to be notified of when a window is iconified, and no way to * check whether a window is currently iconified. * @@ -4905,7 +4905,7 @@ GLFWAPI int glfwGetKeyScancode(int key); * @sa @ref input_key * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup input */ @@ -4937,7 +4937,7 @@ GLFWAPI int glfwGetKey(GLFWwindow* window, int key); * @sa @ref input_mouse_button * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup input */ @@ -5007,7 +5007,7 @@ GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks). * - * @remark @wayland This function will only work when the cursor mode is + * @remark __Wayland:__ This function will only work when the cursor mode is * `GLFW_CURSOR_DISABLED`, otherwise it will emit @ref GLFW_FEATURE_UNAVAILABLE. * * @thread_safety This function must only be called from the main thread. @@ -5205,7 +5205,7 @@ GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); * @sa @ref input_key * * @since Added in version 1.0. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup input */ @@ -5248,7 +5248,7 @@ GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback); * @sa @ref input_char * * @since Added in version 2.4. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup input */ @@ -5332,7 +5332,7 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods * @sa @ref input_mouse_button * * @since Added in version 1.0. - * @glfw3 Added window handle parameter and return value. + * __GLFW 3:__ Added window handle parameter and return value. * * @ingroup input */ @@ -5562,7 +5562,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count); * @sa @ref joystick_button * * @since Added in version 2.2. - * @glfw3 Changed to return a dynamic array. + * __GLFW 3:__ Changed to return a dynamic array. * * @ingroup input */ @@ -5926,7 +5926,7 @@ 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 + * @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. @@ -5959,7 +5959,7 @@ 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 + * @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. @@ -6176,7 +6176,7 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void); * @sa @ref glfwSwapInterval * * @since Added in version 1.0. - * @glfw3 Added window handle parameter. + * __GLFW 3:__ Added window handle parameter. * * @ingroup window */ @@ -6443,7 +6443,7 @@ GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* p * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. * - * @remark @macos This function currently always returns `GLFW_TRUE`, as the + * @remark __macOS:__ This function currently always returns `GLFW_TRUE`, as the * `VK_MVK_macos_surface` and `VK_EXT_metal_surface` extensions do not provide * a `vkGetPhysicalDevice*PresentationSupport` type function. * @@ -6501,15 +6501,15 @@ GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhys * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should * eliminate almost all occurrences of these errors. * - * @remark @macos GLFW prefers the `VK_EXT_metal_surface` extension, with the + * @remark __macOS:__ GLFW prefers the `VK_EXT_metal_surface` extension, with the * `VK_MVK_macos_surface` extension as a fallback. The name of the selected * extension, if any, is included in the array returned by @ref * glfwGetRequiredInstanceExtensions. * - * @remark @macos This function creates and sets a `CAMetalLayer` instance for + * @remark __macOS:__ This function creates and sets a `CAMetalLayer` instance for * the window content view, which is required for MoltenVK to function. * - * @remark @x11 By default GLFW prefers the `VK_KHR_xcb_surface` extension, + * @remark __X11:__ By default GLFW prefers the `VK_KHR_xcb_surface` extension, * with the `VK_KHR_xlib_surface` extension as a fallback. You can make * `VK_KHR_xlib_surface` the preferred extension by setting the * [GLFW_X11_XCB_VULKAN_SURFACE](@ref GLFW_X11_XCB_VULKAN_SURFACE_hint) init From 4c64184455f393b85ca55408ece3e8c596af7050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 13 Mar 2024 00:19:11 +0100 Subject: [PATCH 050/112] Remove title member from window config The window title is already available in the window struct. --- src/cocoa_window.m | 2 +- src/internal.h | 1 - src/win32_window.c | 2 +- src/window.c | 1 - src/x11_window.c | 10 +++++----- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index e69b5fe0c..2bff22a6b 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -884,7 +884,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, [window->ns.object setContentView:window->ns.view]; [window->ns.object makeFirstResponder:window->ns.view]; - [window->ns.object setTitle:@(wndconfig->title)]; + [window->ns.object setTitle:@(window->title)]; [window->ns.object setDelegate:window->ns.delegate]; [window->ns.object setAcceptsMouseMovedEvents:YES]; [window->ns.object setRestorable:NO]; diff --git a/src/internal.h b/src/internal.h index 4f097aa82..de703740f 100644 --- a/src/internal.h +++ b/src/internal.h @@ -402,7 +402,6 @@ struct _GLFWwndconfig int ypos; int width; int height; - const char* title; GLFWbool resizable; GLFWbool visible; GLFWbool decorated; diff --git a/src/win32_window.c b/src/win32_window.c index 26f9684b7..6427a673e 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1377,7 +1377,7 @@ static int createNativeWindow(_GLFWwindow* window, frameHeight = rect.bottom - rect.top; } - wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title); + wideTitle = _glfwCreateWideStringFromUTF8Win32(window->title); if (!wideTitle) return GLFW_FALSE; diff --git a/src/window.c b/src/window.c index e03121a46..3a3b66dfe 100644 --- a/src/window.c +++ b/src/window.c @@ -208,7 +208,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, wndconfig.width = width; wndconfig.height = height; - wndconfig.title = title; ctxconfig.share = (_GLFWwindow*) share; if (!_glfwIsValidContextConfig(&ctxconfig)) diff --git a/src/x11_window.c b/src/x11_window.c index 322349f08..986bfb93b 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -754,13 +754,13 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, const char* resourceName = getenv("RESOURCE_NAME"); if (resourceName && strlen(resourceName)) hint->res_name = (char*) resourceName; - else if (strlen(wndconfig->title)) - hint->res_name = (char*) wndconfig->title; + else if (strlen(window->title)) + hint->res_name = (char*) window->title; else hint->res_name = (char*) "glfw-application"; - if (strlen(wndconfig->title)) - hint->res_class = (char*) wndconfig->title; + if (strlen(window->title)) + hint->res_class = (char*) window->title; else hint->res_class = (char*) "GLFW-Application"; } @@ -780,7 +780,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, if (_glfw.x11.im) _glfwCreateInputContextX11(window); - _glfwSetWindowTitleX11(window, wndconfig->title); + _glfwSetWindowTitleX11(window, window->title); _glfwGetWindowPosX11(window, &window->x11.xpos, &window->x11.ypos); _glfwGetWindowSizeX11(window, &window->x11.width, &window->x11.height); From 1a0b7827d45238e23df05f13dee47dda331bde05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 29 Aug 2025 17:08:36 +0200 Subject: [PATCH 051/112] EGL: Fix error return value for glfwGetEGLSurface This is a semantic fix only. The behavior is unchanged. --- src/egl_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/egl_context.c b/src/egl_context.c index 517c64cb2..272e7a4d2 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -939,7 +939,7 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) window->context.source != GLFW_NATIVE_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return EGL_NO_CONTEXT; + return EGL_NO_SURFACE; } } From 621e99d53ec3a49033f59e2656436d607812f5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 29 Aug 2025 15:44:34 +0200 Subject: [PATCH 052/112] Add glfwGetEGLConfig native access function This adds the glfwGetEGLConfig function for querying the EGLConfig of the EGLSurface of a window. This is a re-implementation of the PR #2045 by knokko, slightly redesigned to handle EGLConfig being an opaque type in core EGL. Closes #2045 --- CONTRIBUTORS.md | 1 + README.md | 1 + docs/news.md | 10 ++++++++++ include/GLFW/glfw3native.h | 23 +++++++++++++++++++++++ src/egl_context.c | 22 ++++++++++++++++++++++ 5 files changed, 57 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 22ef76d0a..cfb4f42ca 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -124,6 +124,7 @@ video tutorials. - Josh Kilmer - Byunghoon Kim - Cameron King + - knokko - Peter Knut - Christoph Kubisch - Yuri Kunde Schlesner diff --git a/README.md b/README.md index 5148467a7..cfb748f9f 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,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) + - Added `glfwGetEGLConfig` function to query the `EGLConfig` of a window (#2045) - Updated minimum CMake version to 3.16 (#2541) - Removed support for building with original MinGW (#2540) - [Win32] Removed support for Windows XP and Vista (#2505) diff --git a/docs/news.md b/docs/news.md index 640ae7a57..0e0cb029b 100644 --- a/docs/news.md +++ b/docs/news.md @@ -14,6 +14,13 @@ 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. + +### EGLConfig native access function {#eglconfig} + +GLFW now provides the @ref glfwGetEGLConfig native access function for querying +the `EGLConfig` of a window that has a `EGLSurface`. + + ## Caveats {#caveats} ## Deprecations {#deprecations} @@ -39,6 +46,9 @@ actively maintained and available on many platforms. ### New functions {#new_functions} + - @ref glfwGetEGLConfig + + ### New types {#new_types} ### New constants {#new_constants} diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 011b239c8..0071d12bf 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -586,6 +586,29 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window); * @ingroup native */ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); + +/*! @brief Retrieves the `EGLConfig` of the specified window's `EGLSurface`. + * + * @param[in] window The window whose `EGLSurface` to query. + * @param[out] config The `EGLConfig` of the window `EGLSurface`, if available. + * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref + * GLFW_NO_WINDOW_CONTEXT. + * + * @remark `EGLConfig` is an opaque type. Unlike other GLFW functions, the @p + * config out parameter is not cleared on error, as core EGL does not define + * any invalid value. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @since Added in version 3.5. + * + * @ingroup native + */ +GLFWAPI int glfwGetEGLConfig(GLFWwindow* window, EGLConfig* config); #endif #if defined(GLFW_EXPOSE_NATIVE_OSMESA) diff --git a/src/egl_context.c b/src/egl_context.c index 272e7a4d2..0ef7f7295 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -946,3 +946,25 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) return window->context.egl.surface; } +GLFWAPI int glfwGetEGLConfig(GLFWwindow* handle, EGLConfig* config) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); + + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + assert(config != NULL); + + if (window->context.source != GLFW_EGL_CONTEXT_API) + { + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND || + window->context.source != GLFW_NATIVE_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return GLFW_FALSE; + } + } + + *config = window->context.egl.config; + return GLFW_TRUE; +} + From 8e15281d34a8b9ee9271ccce38177a3d812456f8 Mon Sep 17 00:00:00 2001 From: knokko Date: Sun, 27 Jun 2021 17:36:01 +0200 Subject: [PATCH 053/112] Add glfwGetGLXFBConfig native access function This adds the glfwGetGLXFBConfig function for querying the GLXFBConfig the GLXWindow of a window. This commit is a squashed and modified version of PR #1925 by knokko. The following changes were made by elmindreda: The function signature was changed to handle GLXFBConfig being an opaque value in core GLX. The function error checks were fixed and updated. The struct member name was changed. The struct member clearing on context destruction was removed. All documentation snippets were updated. Closes #1925 --- README.md | 1 + docs/news.md | 7 +++++++ include/GLFW/glfw3native.h | 23 +++++++++++++++++++++++ src/glx_context.c | 26 ++++++++++++++++++++++++++ src/x11_platform.h | 1 + 5 files changed, 58 insertions(+) diff --git a/README.md b/README.md index cfb748f9f..1c7ced36e 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) - Added `glfwGetEGLConfig` function to query the `EGLConfig` of a window (#2045) + - Added `glfwGetGLXFBConfig` function to query the `GLXFBConfig` of a window (#1925) - Updated minimum CMake version to 3.16 (#2541) - Removed support for building with original MinGW (#2540) - [Win32] Removed support for Windows XP and Vista (#2505) diff --git a/docs/news.md b/docs/news.md index 0e0cb029b..f752ce427 100644 --- a/docs/news.md +++ b/docs/news.md @@ -21,6 +21,12 @@ GLFW now provides the @ref glfwGetEGLConfig native access function for querying the `EGLConfig` of a window that has a `EGLSurface`. +### GLXFBConfig native access function {#glxfbconfig} + +GLFW now provides the @ref glfwGetGLXFBConfig native access function for +querying the `GLXFBConfig` of a window that has a `GLXWindow`. + + ## Caveats {#caveats} ## Deprecations {#deprecations} @@ -47,6 +53,7 @@ actively maintained and available on many platforms. ### New functions {#new_functions} - @ref glfwGetEGLConfig + - @ref glfwGetGLXFBConfig ### New types {#new_types} diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 0071d12bf..8db2cfa3b 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -478,6 +478,29 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); * @ingroup native */ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); + +/*! @brief Retrieves the `GLXFBConfig` of the specified window's `GLXWindow`. + * + * @param[in] window The window whose `GLXWindow` to query. + * @param[out] config The `GLXFBConfig` of the window `GLXWindow`, if available. + * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref + * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_UNAVAILABLE. + * + * @remark `GLXFBConfig` is an opaque type. Unlike other GLFW functions, the + * @p config out parameter is not cleared on error, as core GLX does not define + * any invalid value. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @since Added in version 3.5 + * + * @ingroup native + */ +GLFWAPI int glfwGetGLXFBConfig(GLFWwindow* window, GLXFBConfig* config); #endif #if defined(GLFW_EXPOSE_NATIVE_WAYLAND) diff --git a/src/glx_context.c b/src/glx_context.c index a2464a9d6..098c4bade 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -626,6 +626,8 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, return GLFW_FALSE; } + window->context.glx.fbconfig = native; + window->context.makeCurrent = makeContextCurrentGLX; window->context.swapBuffers = swapBuffersGLX; window->context.swapInterval = swapIntervalGLX; @@ -719,5 +721,29 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) return window->context.glx.window; } +GLFWAPI int glfwGetGLXFBConfig(GLFWwindow* handle, GLXFBConfig* config) +{ + _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE); + + if (_glfw.platform.platformID != GLFW_PLATFORM_X11) + { + _glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "GLX: Platform not initialized"); + return GLFW_FALSE; + } + + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + assert(config != NULL); + + if (window->context.source != GLFW_NATIVE_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return GLFW_FALSE; + } + + *config = window->context.glx.fbconfig; + return GLFW_TRUE; +} + #endif // _GLFW_X11 diff --git a/src/x11_platform.h b/src/x11_platform.h index 30326c5be..1bfeaab49 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -470,6 +470,7 @@ typedef struct _GLFWcontextGLX { GLXContext handle; GLXWindow window; + GLXFBConfig fbconfig; } _GLFWcontextGLX; // GLX-specific global data From 6de70d82522a8b884b1b271686707697ce193238 Mon Sep 17 00:00:00 2001 From: Ivor Wanders Date: Sat, 9 Aug 2025 11:13:20 -0400 Subject: [PATCH 054/112] X11: Prevent BadWindow when creating small windows The glfwCreateWindow function ensures that the width and height are at least greater or equal than zero, but on X11 it is invalid to create a window with dimensions that equal zero, see [1]. This change ensures that the dimensions passed to XCreateWindow are at least 1 by 1. This issue was detected in [2], where a call to glfwCreateWindow was done to request a 1x1 window, with a _glfw.x11.contentScaleX of less than 1.0 (0.958333) this results in a request for a 0x0 window which then causes an BadWindow error from X11. [1]: https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/e003f52661679e95b51ff24e317af6178fe2a73c/specs/libX11/CH03.xml#L1333-1337 [2]: https://github.com/WerWolv/ImHex/pull/2390 --- CONTRIBUTORS.md | 1 + README.md | 2 ++ src/x11_window.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index cfb4f42ca..e3956e61d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -282,6 +282,7 @@ video tutorials. - Corentin Wallez - Torsten Walluhn - Patrick Walton + - Ivor Wanders - Jim Wang - Xo Wang - Andre Weissflog diff --git a/README.md b/README.md index 1c7ced36e..5e882e277 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,8 @@ information on what to include when reporting a bug. - [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) + - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale + less than 1 (#2754) ## Contact diff --git a/src/x11_window.c b/src/x11_window.c index 986bfb93b..65d7eb2cb 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -576,6 +576,10 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, height *= _glfw.x11.contentScaleY; } + // The dimensions must be nonzero, or a BadValue error results. + width = _glfw_max(1, width); + height = _glfw_max(1, height); + int xpos = 0, ypos = 0; if (wndconfig->xpos != GLFW_ANY_POSITION && wndconfig->ypos != GLFW_ANY_POSITION) From 4df5129529b1af57d04a51f09145da5079822c3e Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sat, 6 Sep 2025 07:33:27 -0700 Subject: [PATCH 055/112] X11: check crtcInfo for NULL when polling monitors --- CONTRIBUTORS.md | 1 + README.md | 1 + src/x11_monitor.c | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e3956e61d..0e1d88342 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -287,6 +287,7 @@ video tutorials. - Xo Wang - Andre Weissflog - Jay Weisskopf + - Drew Weymouth - Frank Wille - Andy Williams - Joel Winarske diff --git a/README.md b/README.md index 5e882e277..586d6be25 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: The cursor position was not updated when clicking through from a modal to the content area - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) + - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [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/x11_monitor.c b/src/x11_monitor.c index 3af827520..74c57ed01 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -151,6 +151,11 @@ void _glfwPollMonitorsX11(void) } XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc); + if (!ci) { + XRRFreeOutputInfo(oi); + continue; + } + if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270) { widthMM = oi->mm_height; From 936307558ee25bf5d50d7ecf22972efd4c3abd4f Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Sat, 8 Nov 2025 10:37:52 +0000 Subject: [PATCH 056/112] X11: Clamp w,h in glfwSetWindowSize to >= 1 - prevents BadValue error and program exit --- README.md | 5 +++-- src/x11_window.c | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 586d6be25..528054e2c 100644 --- a/README.md +++ b/README.md @@ -146,12 +146,13 @@ information on what to include when reporting a bug. from a modal to the content area - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) + - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale + less than 1 (#2754) + - [X11] Bugfix: Clamp width and height to >= 1 to prevent BadValue error and app exit - [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) - - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale - less than 1 (#2754) ## Contact diff --git a/src/x11_window.c b/src/x11_window.c index 65d7eb2cb..02c4ab58d 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2207,6 +2207,10 @@ void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height) void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height) { + // The dimensions must be nonzero, or a BadValue error results. + width = _glfw_max(1, width); + height = _glfw_max(1, height); + if (window->monitor) { if (window->monitor->window == window) From 162896e5b9a40dc382c5c438cd12c90a5ff86ddd Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Fri, 14 Nov 2025 16:35:47 +0000 Subject: [PATCH 057/112] Wayland: free modules at end of terminate function - Fixes #2744 --- README.md | 2 ++ src/egl_context.c | 3 ++- src/wl_init.c | 52 +++++++++++++++++++++++++++-------------------- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 528054e2c..9bad25a0f 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,8 @@ information on what to include when reporting a bug. a modal to a fallback decoration - [Wayland] Bugfix: The cursor position was not updated when clicking through from a modal to the content area + - [Wayland] Bugfix: free modules at end of terminate function to resolve + potential segmentation fault (#2744) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/egl_context.c b/src/egl_context.c index 0ef7f7295..921d5c6eb 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -555,7 +555,8 @@ void _glfwTerminateEGL(void) _glfw.egl.display = EGL_NO_DISPLAY; } - if (_glfw.egl.handle) + // Free modules only after all wayland termination functions are called + if (_glfw.egl.handle && _glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) { _glfwPlatformFreeModule(_glfw.egl.handle); _glfw.egl.handle = NULL; diff --git a/src/wl_init.c b/src/wl_init.c index ef9e45036..704906381 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -907,18 +907,6 @@ void _glfwTerminateWayland(void) libdecor_unref(_glfw.wl.libdecor.context); } - if (_glfw.wl.libdecor.handle) - { - _glfwPlatformFreeModule(_glfw.wl.libdecor.handle); - _glfw.wl.libdecor.handle = NULL; - } - - if (_glfw.wl.egl.handle) - { - _glfwPlatformFreeModule(_glfw.wl.egl.handle); - _glfw.wl.egl.handle = NULL; - } - if (_glfw.wl.xkb.composeState) xkb_compose_state_unref(_glfw.wl.xkb.composeState); if (_glfw.wl.xkb.keymap) @@ -927,21 +915,11 @@ void _glfwTerminateWayland(void) xkb_state_unref(_glfw.wl.xkb.state); if (_glfw.wl.xkb.context) xkb_context_unref(_glfw.wl.xkb.context); - if (_glfw.wl.xkb.handle) - { - _glfwPlatformFreeModule(_glfw.wl.xkb.handle); - _glfw.wl.xkb.handle = NULL; - } if (_glfw.wl.cursorTheme) wl_cursor_theme_destroy(_glfw.wl.cursorTheme); if (_glfw.wl.cursorThemeHiDPI) wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI); - if (_glfw.wl.cursor.handle) - { - _glfwPlatformFreeModule(_glfw.wl.cursor.handle); - _glfw.wl.cursor.handle = NULL; - } for (unsigned int i = 0; i < _glfw.wl.offerCount; i++) wl_data_offer_destroy(_glfw.wl.offers[i].offer); @@ -1001,6 +979,36 @@ void _glfwTerminateWayland(void) if (_glfw.wl.cursorTimerfd >= 0) close(_glfw.wl.cursorTimerfd); + // Free modules only after all wayland termination functions are called + if (_glfw.egl.handle) + { + _glfwPlatformFreeModule(_glfw.egl.handle); + _glfw.egl.handle = NULL; + } + + if (_glfw.wl.libdecor.handle) + { + _glfwPlatformFreeModule(_glfw.wl.libdecor.handle); + _glfw.wl.libdecor.handle = NULL; + } + + if (_glfw.wl.egl.handle) + { + _glfwPlatformFreeModule(_glfw.wl.egl.handle); + _glfw.wl.egl.handle = NULL; + } + + if (_glfw.wl.xkb.handle) + { + _glfwPlatformFreeModule(_glfw.wl.xkb.handle); + _glfw.wl.xkb.handle = NULL; + } + if (_glfw.wl.cursor.handle) + { + _glfwPlatformFreeModule(_glfw.wl.cursor.handle); + _glfw.wl.cursor.handle = NULL; + } + _glfw_free(_glfw.wl.clipboardString); } From ebff6606ee1e30f12859c6c308452110022a4aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 1 Sep 2025 17:27:07 +0200 Subject: [PATCH 058/112] Simplify test for shared library build --- CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 398b36eb1..063533c4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,11 +38,7 @@ set(GLFW_LIBRARY_TYPE "${GLFW_LIBRARY_TYPE}" CACHE STRING "Library type override for GLFW (SHARED, STATIC, OBJECT, or empty to follow BUILD_SHARED_LIBS)") if (GLFW_LIBRARY_TYPE) - if (GLFW_LIBRARY_TYPE STREQUAL "SHARED") - set(GLFW_BUILD_SHARED_LIBRARY TRUE) - else() - set(GLFW_BUILD_SHARED_LIBRARY FALSE) - endif() + string(COMPARE EQUAL "${GLFW_LIBRARY_TYPE}" "SHARED" GLFW_BUILD_SHARED_LIBRARY) else() set(GLFW_BUILD_SHARED_LIBRARY ${BUILD_SHARED_LIBS}) endif() From 1ce855b0b1c8c7418ef2925d75f3b7f366ff5cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 1 Sep 2025 18:43:26 +0200 Subject: [PATCH 059/112] Wayland: Fix missing checks for optional protocol --- README.md | 2 ++ src/wl_window.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9bad25a0f..89aaaac95 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,8 @@ information on what to include when reporting a bug. from a modal to the content area - [Wayland] Bugfix: free modules at end of terminate function to resolve potential segmentation fault (#2744) + - [Wayland] Bugfix: Confining or disabling the cursor could segfault on + compositors without `pointer-constraints-unstable-v1` - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/wl_window.c b/src/wl_window.c index 4220d17e0..1bb32f5f0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2974,10 +2974,16 @@ static void lockPointer(_GLFWwindow* window) if (!_glfw.wl.relativePointerManager) { _glfwInputError(GLFW_FEATURE_UNAVAILABLE, - "Wayland: The compositor does not support pointer locking"); + "Wayland: The compositor does not support relative pointer motion"); return; } + if (!_glfw.wl.pointerConstraints) + { + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The compositor does not support locking the pointer"); + } + window->wl.relativePointer = zwp_relative_pointer_manager_v1_get_relative_pointer( _glfw.wl.relativePointerManager, @@ -3025,6 +3031,12 @@ static const struct zwp_confined_pointer_v1_listener confinedPointerListener = static void confinePointer(_GLFWwindow* window) { + if (!_glfw.wl.pointerConstraints) + { + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The compositor does not support confining the pointer"); + } + window->wl.confinedPointer = zwp_pointer_constraints_v1_confine_pointer( _glfw.wl.pointerConstraints, From 08449b71830c82d5341b97d3eb84261106552ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 25 Nov 2025 19:46:34 +0100 Subject: [PATCH 060/112] Linux: Add missing header for ioctl Fixes #2778 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/linux_joystick.c | 1 + 3 files changed, 3 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 0e1d88342..031962ecd 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -162,6 +162,7 @@ video tutorials. - Marcel Metz - Liam Middlebrook - mightgoyardstill + - Mihail - Ave Milia - Icyllis Milica - Jonathan Miller diff --git a/README.md b/README.md index 89aaaac95..b27ea51dd 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale less than 1 (#2754) - [X11] Bugfix: Clamp width and height to >= 1 to prevent BadValue error and app exit + - [Linux] Bugfix: The header for `ioctl` was only implicitly included (#2778) - [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/linux_joystick.c b/src/linux_joystick.c index d8a916b08..e4d2852b3 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include From dbadda26835ec5089ef922e6c290bcf58cf12056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Aug 2025 18:03:35 +0200 Subject: [PATCH 061/112] Formatting --- src/win32_init.c | 3 ++- src/wl_init.c | 4 +++- src/wl_platform.h | 8 ++++++-- src/wl_window.c | 9 ++++++--- src/x11_monitor.c | 3 ++- src/x11_window.c | 4 ++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/win32_init.c b/src/win32_init.c index 6b6e9d08e..90e47670e 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -528,7 +528,8 @@ void _glfwUpdateKeyNamesWin32(void) if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_ADD) { - const UINT vks[] = { + const UINT vks[] = + { VK_NUMPAD0, VK_NUMPAD1, VK_NUMPAD2, VK_NUMPAD3, VK_NUMPAD4, VK_NUMPAD5, VK_NUMPAD6, VK_NUMPAD7, VK_NUMPAD8, VK_NUMPAD9, VK_DECIMAL, VK_DIVIDE, diff --git a/src/wl_init.c b/src/wl_init.c index 704906381..d32c4adf4 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -979,7 +979,8 @@ void _glfwTerminateWayland(void) if (_glfw.wl.cursorTimerfd >= 0) close(_glfw.wl.cursorTimerfd); - // Free modules only after all wayland termination functions are called + // Free modules only after all Wayland termination functions are called + if (_glfw.egl.handle) { _glfwPlatformFreeModule(_glfw.egl.handle); @@ -1003,6 +1004,7 @@ void _glfwTerminateWayland(void) _glfwPlatformFreeModule(_glfw.wl.xkb.handle); _glfw.wl.xkb.handle = NULL; } + if (_glfw.wl.cursor.handle) { _glfwPlatformFreeModule(_glfw.wl.cursor.handle); diff --git a/src/wl_platform.h b/src/wl_platform.h index c3e456931..bdadb657e 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -136,18 +136,22 @@ struct wl_output; #define GLFW_WAYLAND_MONITOR_STATE _GLFWmonitorWayland wl; #define GLFW_WAYLAND_CURSOR_STATE _GLFWcursorWayland wl; -struct wl_cursor_image { +struct wl_cursor_image +{ uint32_t width; uint32_t height; uint32_t hotspot_x; uint32_t hotspot_y; uint32_t delay; }; -struct wl_cursor { + +struct wl_cursor +{ unsigned int image_count; struct wl_cursor_image** images; char* name; }; + typedef struct wl_cursor_theme* (* PFN_wl_cursor_theme_load)(const char*, int, struct wl_shm*); typedef void (* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme*); typedef struct wl_cursor* (* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme*, const char*); diff --git a/src/wl_window.c b/src/wl_window.c index 1bb32f5f0..ad39b2e0e 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1413,7 +1413,7 @@ static void handleEvents(double* timeout) if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8) { - if(_glfw.wl.keyboardFocus) + if (_glfw.wl.keyboardFocus) { for (uint64_t i = 0; i < repeats; i++) { @@ -1692,7 +1692,8 @@ static void keyboardHandleKeymap(void* userData, } mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); - if (mapStr == MAP_FAILED) { + if (mapStr == MAP_FAILED) + { close(fd); return; } @@ -1838,7 +1839,9 @@ static void keyboardHandleKey(void* userData, timer.it_value.tv_nsec = (_glfw.wl.keyRepeatDelay % 1000) * 1000000; timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); } - } else if (scancode == _glfw.wl.keyRepeatScancode) { + } + else if (scancode == _glfw.wl.keyRepeatScancode) + { timerfd_settime(_glfw.wl.keyRepeatTimerfd, 0, &timer, NULL); } diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 74c57ed01..abf9cbff5 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -151,7 +151,8 @@ void _glfwPollMonitorsX11(void) } XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc); - if (!ci) { + if (!ci) + { XRRFreeOutputInfo(oi); continue; } diff --git a/src/x11_window.c b/src/x11_window.c index 02c4ab58d..045878aa5 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2207,10 +2207,10 @@ void _glfwGetWindowSizeX11(_GLFWwindow* window, int* width, int* height) void _glfwSetWindowSizeX11(_GLFWwindow* window, int width, int height) { - // The dimensions must be nonzero, or a BadValue error results. + // The dimensions must be nonzero, or a BadValue error results width = _glfw_max(1, width); height = _glfw_max(1, height); - + if (window->monitor) { if (window->monitor->window == window) From a228a8b447394f19eaad8988b92d96c01e998c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 12 Jan 2026 18:29:52 +0100 Subject: [PATCH 062/112] X11: Fix window made non-floating by being hidden The previous implementation was based on the incorrect assumption that the _NET_WM_STATE_ABOVE state is always retained on unmapped windows. According to EWMH the WM should remove the _NET_WM_STATE property when a window is unmapped. This commit moves the adding of _NET_WM_STATE_ABOVE to before mapping the window during glfwShowWindow. The logic for removing _NET_WM_STATE_ABOVE from hidden windows is retained, as EWMH still allows WMs to leave the window property on unmapped window. Fixes #2276 --- README.md | 1 + src/x11_window.c | 57 +++++++++++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b27ea51dd..b05132e7b 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale less than 1 (#2754) - [X11] Bugfix: Clamp width and height to >= 1 to prevent BadValue error and app exit + - [X11] Bugfix: Floating windows silently became non-floating when hidden (#2276) - [Linux] Bugfix: The header for `ioctl` was only implicitly included (#2778) - [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/x11_window.c b/src/x11_window.c index 045878aa5..5fc42b4a2 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2438,6 +2438,38 @@ void _glfwShowWindowX11(_GLFWwindow* window) if (_glfwWindowVisibleX11(window)) return; + if (window->floating && _glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_ABOVE) + { + Atom* states = NULL; + const unsigned long count = + _glfwGetWindowPropertyX11(window->x11.handle, + _glfw.x11.NET_WM_STATE, + XA_ATOM, (unsigned char**) &states); + + // NOTE: We don't check for failure as this property may not exist yet + // and that's fine (and we'll create it implicitly with append) + + unsigned long i; + + for (i = 0; i < count; i++) + { + if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE) + break; + } + + if (i == count) + { + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_STATE, XA_ATOM, 32, + PropModeAppend, + (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE, + 1); + } + + if (states) + XFree(states); + } + XMapWindow(_glfw.x11.display, window->x11.handle); waitForVisibilityNotify(window); } @@ -2667,6 +2699,10 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled) } else { + // NOTE: _NET_WM_STATE_ABOVE is added when the window is shown + if (enabled) + return; + Atom* states = NULL; const unsigned long count = _glfwGetWindowPropertyX11(window->x11.handle, @@ -2677,26 +2713,7 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled) // NOTE: We don't check for failure as this property may not exist yet // and that's fine (and we'll create it implicitly with append) - if (enabled) - { - unsigned long i; - - for (i = 0; i < count; i++) - { - if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE) - break; - } - - if (i == count) - { - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.NET_WM_STATE, XA_ATOM, 32, - PropModeAppend, - (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE, - 1); - } - } - else if (states) + if (states) { for (unsigned long i = 0; i < count; i++) { From 9352d8fe93cd443be18157abe81f16500549aec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 12 Jan 2026 19:16:35 +0100 Subject: [PATCH 063/112] X11: Cleanup --- src/x11_window.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 5fc42b4a2..9a84e5c72 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2713,19 +2713,20 @@ void _glfwSetWindowFloatingX11(_GLFWwindow* window, GLFWbool enabled) // NOTE: We don't check for failure as this property may not exist yet // and that's fine (and we'll create it implicitly with append) - if (states) + unsigned long i; + + for (i = 0; i < count; i++) { - for (unsigned long i = 0; i < count; i++) - { - if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE) - { - states[i] = states[count - 1]; - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.NET_WM_STATE, XA_ATOM, 32, - PropModeReplace, (unsigned char*) states, count - 1); - break; - } - } + if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE) + break; + } + + if (i < count) + { + states[i] = states[count - 1]; + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.NET_WM_STATE, XA_ATOM, 32, + PropModeReplace, (unsigned char*) states, count - 1); } if (states) From 96e0f4939565602fd418008f8dde2f108665d8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 6 Jan 2026 20:12:48 +0100 Subject: [PATCH 064/112] X11: Place argument assertion after platform check This lets automated testing check that GLFW_NOT_INITIALIZED is emitted for every public function. --- src/x11_window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index 9a84e5c72..47b9ad1e2 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -3344,8 +3344,6 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* handle) GLFWAPI void glfwSetX11SelectionString(const char* string) { - assert(string != NULL); - _GLFW_REQUIRE_INIT(); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -3354,6 +3352,8 @@ GLFWAPI void glfwSetX11SelectionString(const char* string) return; } + assert(string != NULL); + _glfw_free(_glfw.x11.primarySelectionString); _glfw.x11.primarySelectionString = _glfw_strdup(string); From 2d7ae8f2d0a93efb8db3a82170b18266540e333f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Jan 2026 21:09:01 +0100 Subject: [PATCH 065/112] Wayland: Cleanup This is only a semantic change. The values are the same. --- src/wl_init.c | 2 +- src/wl_window.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index d32c4adf4..1d0d3ef82 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -834,7 +834,7 @@ int _glfwInitWayland(void) createKeyTables(); - _glfw.wl.xkb.context = xkb_context_new(0); + _glfw.wl.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); if (!_glfw.wl.xkb.context) { _glfwInputError(GLFW_PLATFORM_ERROR, diff --git a/src/wl_window.c b/src/wl_window.c index ad39b2e0e..7c0d3e19d 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1701,7 +1701,7 @@ static void keyboardHandleKeymap(void* userData, keymap = xkb_keymap_new_from_string(_glfw.wl.xkb.context, mapStr, XKB_KEYMAP_FORMAT_TEXT_V1, - 0); + XKB_KEYMAP_COMPILE_NO_FLAGS); munmap(mapStr, size); close(fd); From bafb134769bbbecc196016576b968e6c08212ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 22 Jan 2026 16:23:40 +0100 Subject: [PATCH 066/112] Documentation work Elaborate on what 'work' means in the context of joystick input. --- include/GLFW/glfw3.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 3ce1c0191..58989cc7a 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -4520,7 +4520,8 @@ GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* * GLFW will pass those events on to the application callbacks before * returning. * - * Event processing is not required for joystick input to work. + * Event processing is not required to receive joystick input. Joystick state + * is polled when a joystick input or gamepad input function is called. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. @@ -4565,7 +4566,8 @@ GLFWAPI void glfwPollEvents(void); * GLFW will pass those events on to the application callbacks before * returning. * - * Event processing is not required for joystick input to work. + * Event processing is not required to receive joystick input. Joystick state + * is polled when a joystick input or gamepad input function is called. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. @@ -4612,7 +4614,8 @@ GLFWAPI void glfwWaitEvents(void); * GLFW will pass those events on to the application callbacks before * returning. * - * Event processing is not required for joystick input to work. + * Event processing is not required to receive joystick input. Joystick state + * is polled when a joystick input or gamepad input function is called. * * @param[in] timeout The maximum amount of time, in seconds, to wait. * From f871f14d5e34a8e1796cf881556d160949b592e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 22 Jan 2026 16:28:24 +0100 Subject: [PATCH 067/112] Add update flag to timeout test Redrawing the window contents for every possible event is not a reasonable thing for an application to do. The test should be whether redrawing on demand plus periodic updates works with near-idle CPU use and no extra input latency. This change incidentally makes the test well-behaved on Wayland, where it was previously broken due to every EGL buffer swap causing an event to be received. --- tests/timeout.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/timeout.c b/tests/timeout.c index c27374620..1d3b09ef3 100644 --- a/tests/timeout.c +++ b/tests/timeout.c @@ -36,6 +36,14 @@ #include #include #include +#include + +static bool needs_update; + +static void window_close_callback(GLFWwindow* window) +{ + needs_update = true; +} static void error_callback(int error, const char* description) { @@ -45,7 +53,15 @@ static void error_callback(int error, const char* description) 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); + needs_update = true; + } +} + +static void framebuffer_size_callback(GLFWwindow* window, int width, int height) +{ + needs_update = true; } static float nrand(void) @@ -72,8 +88,11 @@ int main(void) } glfwMakeContextCurrent(window); + glfwSwapInterval(0); gladLoadGL(glfwGetProcAddress); + glfwSetWindowCloseCallback(window, window_close_callback); glfwSetKeyCallback(window, key_callback); + glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); while (!glfwWindowShouldClose(window)) { @@ -87,8 +106,18 @@ int main(void) glClearColor(r / l, g / l, b / l, 1.f); glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(window); + needs_update = false; - glfwWaitEventsTimeout(1.0); + const double start = glfwGetTime(); + + while (!needs_update) + { + const double elapsed = glfwGetTime() - start; + if (elapsed >= 1.0) + needs_update = true; + else + glfwWaitEventsTimeout(1.0 - elapsed); + } } glfwDestroyWindow(window); From 7b370d8df0b2b6dee7b7ff145326df3f7d7aab00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 23 Jan 2026 17:43:26 +0100 Subject: [PATCH 068/112] Wayland: Simplify pointer surface state Track which surface contains the pointer with one piece of state instead of three partially overlapping ones. --- src/wl_platform.h | 4 +-- src/wl_window.c | 92 ++++++++++++++++++++++------------------------- 2 files changed, 43 insertions(+), 53 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index bdadb657e..560d0b0c9 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -360,7 +360,6 @@ typedef struct _GLFWwindowWayland GLFWbool maximized; GLFWbool activated; GLFWbool fullscreen; - GLFWbool hovered; GLFWbool transparent; GLFWbool scaleFramebuffer; struct wl_surface* surface; @@ -416,7 +415,6 @@ typedef struct _GLFWwindowWayland GLFWbool decorations; struct wl_buffer* buffer; _GLFWfallbackEdgeWayland top, left, right, bottom; - struct wl_surface* focus; wl_fixed_t pointerX, pointerY; const char* cursorName; } fallback; @@ -457,6 +455,7 @@ typedef struct _GLFWlibraryWayland const char* tag; + struct wl_surface* pointerSurface; struct wl_cursor_theme* cursorTheme; struct wl_cursor_theme* cursorThemeHiDPI; struct wl_surface* cursorSurface; @@ -515,7 +514,6 @@ typedef struct _GLFWlibraryWayland PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym; } xkb; - _GLFWwindow* pointerFocus; _GLFWwindow* keyboardFocus; struct { diff --git a/src/wl_window.c b/src/wl_window.c index 7c0d3e19d..5caa8fa3e 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -253,6 +253,9 @@ static void createFallbackDecorations(_GLFWwindow* window) static void destroyFallbackEdge(_GLFWfallbackEdgeWayland* edge) { + if (edge->surface == _glfw.wl.pointerSurface) + _glfw.wl.pointerSurface = NULL; + if (edge->subsurface) wl_subsurface_destroy(edge->subsurface); if (edge->surface) @@ -288,26 +291,26 @@ static void updateFallbackDecorationCursor(_GLFWwindow* window, if (window->resizable) { - if (window->wl.fallback.focus == window->wl.fallback.top.surface) + if (_glfw.wl.pointerSurface == window->wl.fallback.top.surface) { if (ypos < GLFW_BORDER_SIZE) cursorName = "n-resize"; } - else if (window->wl.fallback.focus == window->wl.fallback.left.surface) + else if (_glfw.wl.pointerSurface == 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) + else if (_glfw.wl.pointerSurface == 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) + else if (_glfw.wl.pointerSurface == window->wl.fallback.bottom.surface) { if (xpos < GLFW_BORDER_SIZE) cursorName = "sw-resize"; @@ -369,28 +372,28 @@ static void handleFallbackDecorationButton(_GLFWwindow* window, { uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; - if (window->wl.fallback.focus == window->wl.fallback.top.surface) + if (_glfw.wl.pointerSurface == window->wl.fallback.top.surface) { if (ypos < 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) + else if (_glfw.wl.pointerSurface == window->wl.fallback.left.surface) { if (ypos < 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) + else if (_glfw.wl.pointerSurface == window->wl.fallback.right.surface) { if (ypos < 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) + else if (_glfw.wl.pointerSurface == window->wl.fallback.bottom.surface) { if (xpos < GLFW_BORDER_SIZE) edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT; @@ -408,7 +411,7 @@ static void handleFallbackDecorationButton(_GLFWwindow* window, if (!window->wl.xdg.toplevel) return; - if (window->wl.fallback.focus != window->wl.fallback.top.surface) + if (_glfw.wl.pointerSurface != window->wl.fallback.top.surface) return; if (ypos < GLFW_BORDER_SIZE) @@ -1267,14 +1270,16 @@ static void setCursorImage(_GLFWwindow* window, wl_surface_commit(surface); } -static void incrementCursorImage(_GLFWwindow* window) +static void incrementCursorImage(void) { - _GLFWcursor* cursor; - - if (!window || !window->wl.hovered) + if (!_glfw.wl.pointerSurface) return; - cursor = window->wl.currentCursor; + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + if (window->wl.surface != _glfw.wl.pointerSurface) + return; + + _GLFWcursor* cursor = window->wl.currentCursor; if (cursor && cursor->wl.cursor) { cursor->wl.currentImage += 1; @@ -1436,7 +1441,7 @@ static void handleEvents(double* timeout) uint64_t repeats; if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8) - incrementCursorImage(_glfw.wl.pointerFocus); + incrementCursorImage(); } if (fds[LIBDECOR_FD].revents & POLLIN) @@ -1527,15 +1532,13 @@ static void pointerHandleEnter(void* userData, if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag) return; - _GLFWwindow* window = wl_surface_get_user_data(surface); - _glfw.wl.serial = serial; _glfw.wl.pointerEnterSerial = serial; - _glfw.wl.pointerFocus = window; + _glfw.wl.pointerSurface = surface; - if (surface == window->wl.surface) + _GLFWwindow* window = wl_surface_get_user_data(surface); + if (window->wl.surface == surface) { - window->wl.hovered = GLFW_TRUE; _glfwSetCursorWayland(window, window->wl.currentCursor); _glfwInputCursorEnter(window, GLFW_TRUE); @@ -1549,10 +1552,7 @@ static void pointerHandleEnter(void* userData, else { if (window->wl.fallback.decorations) - { - window->wl.fallback.focus = surface; updateFallbackDecorationCursor(window, sx, sy); - } } } @@ -1567,25 +1567,16 @@ static void pointerHandleLeave(void* userData, if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag) return; - _GLFWwindow* window = _glfw.wl.pointerFocus; - if (!window) - return; - _glfw.wl.serial = serial; - _glfw.wl.pointerFocus = NULL; + _glfw.wl.pointerSurface = NULL; - if (window->wl.hovered) - { - window->wl.hovered = GLFW_FALSE; + _GLFWwindow* window = wl_surface_get_user_data(surface); + if (window->wl.surface == surface) _glfwInputCursorEnter(window, GLFW_FALSE); - } else { if (window->wl.fallback.decorations) - { - window->wl.fallback.focus = NULL; window->wl.fallback.cursorName = NULL; - } } } @@ -1595,14 +1586,15 @@ static void pointerHandleMotion(void* userData, wl_fixed_t sx, wl_fixed_t sy) { - _GLFWwindow* window = _glfw.wl.pointerFocus; - if (!window) + if (!_glfw.wl.pointerSurface) return; + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + if (window->cursorMode == GLFW_CURSOR_DISABLED) return; - if (window->wl.hovered) + if (window->wl.surface == _glfw.wl.pointerSurface) { window->wl.cursorPosX = wl_fixed_to_double(sx); window->wl.cursorPosY = wl_fixed_to_double(sy); @@ -1622,11 +1614,12 @@ static void pointerHandleButton(void* userData, uint32_t button, uint32_t state) { - _GLFWwindow* window = _glfw.wl.pointerFocus; - if (!window) + if (!_glfw.wl.pointerSurface) return; - if (window->wl.hovered) + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + + if (window->wl.surface == _glfw.wl.pointerSurface) { _glfw.wl.serial = serial; @@ -1648,11 +1641,12 @@ static void pointerHandleAxis(void* userData, uint32_t axis, wl_fixed_t value) { - _GLFWwindow* window = _glfw.wl.pointerFocus; - if (!window) + if (!_glfw.wl.pointerSurface) return; - if (window->wl.hovered) + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + + if (window->wl.surface == _glfw.wl.pointerSurface) { // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) @@ -2223,8 +2217,8 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, void _glfwDestroyWindowWayland(_GLFWwindow* window) { - if (window == _glfw.wl.pointerFocus) - _glfw.wl.pointerFocus = NULL; + if (window->wl.surface == _glfw.wl.pointerSurface) + _glfw.wl.pointerSurface = NULL; if (window == _glfw.wl.keyboardFocus) { @@ -2600,7 +2594,7 @@ GLFWbool _glfwWindowMaximizedWayland(_GLFWwindow* window) GLFWbool _glfwWindowHoveredWayland(_GLFWwindow* window) { - return window->wl.hovered; + return window->wl.surface == _glfw.wl.pointerSurface; } GLFWbool _glfwFramebufferTransparentWayland(_GLFWwindow* window) @@ -3066,9 +3060,7 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) window->wl.currentCursor = 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->wl.hovered) + if (window->wl.surface != _glfw.wl.pointerSurface) return; // Update pointer lock to match cursor mode From 0aa77a9a3a24bae3ccb6b6c44162d055c977d4f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 26 Jan 2026 17:34:58 +0100 Subject: [PATCH 069/112] Wayland: Release input devices where possible On systems with wl_seat verison 3 or later, use release instead of destroy on input devices when they are disconnected. --- src/wl_window.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 5caa8fa3e..5c6ad835e 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1926,7 +1926,11 @@ static void seatHandleCapabilities(void* userData, } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer) { - wl_pointer_destroy(_glfw.wl.pointer); + if (wl_pointer_get_version(_glfw.wl.pointer) >= WL_POINTER_RELEASE_SINCE_VERSION) + wl_pointer_release(_glfw.wl.pointer); + else + wl_pointer_destroy(_glfw.wl.pointer); + _glfw.wl.pointer = NULL; } @@ -1937,7 +1941,11 @@ static void seatHandleCapabilities(void* userData, } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard) { - wl_keyboard_destroy(_glfw.wl.keyboard); + if (wl_keyboard_get_version(_glfw.wl.keyboard) >= WL_KEYBOARD_RELEASE_SINCE_VERSION) + wl_keyboard_release(_glfw.wl.keyboard); + else + wl_keyboard_destroy(_glfw.wl.keyboard); + _glfw.wl.keyboard = NULL; } } From abb9db0d75919337e9f03a2dde77fc9a6f6f19ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 27 Jan 2026 16:53:32 +0100 Subject: [PATCH 070/112] Wayland: Fix fallback decoration button input Fallback decoration mouse button actions were performed for both press and release events. The requests made using a mouse button release serials were presumably (and correctly) discarded by the compositor. This commit removes the generation of these nuisance requests. --- src/wl_window.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 5c6ad835e..ee8e4a61b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -363,8 +363,12 @@ static void updateFallbackDecorationCursor(_GLFWwindow* window, static void handleFallbackDecorationButton(_GLFWwindow* window, uint32_t serial, - uint32_t button) + uint32_t button, + uint32_t state) { + if (state != WL_POINTER_BUTTON_STATE_PRESSED) + return; + const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX); const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY); @@ -1631,7 +1635,7 @@ static void pointerHandleButton(void* userData, else { if (window->wl.fallback.decorations) - handleFallbackDecorationButton(window, serial, button); + handleFallbackDecorationButton(window, serial, button, state); } } From 232164f62b0edbf667cba37c91bab92ffbb020d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 30 Jan 2026 14:00:55 +0100 Subject: [PATCH 071/112] Wayland: Remove duplicate cursor state The shared window struct already tracks the current cursor. --- src/wl_platform.h | 1 - src/wl_window.c | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index 560d0b0c9..c2ddb732c 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -388,7 +388,6 @@ typedef struct _GLFWwindowWayland struct libdecor_frame* frame; } libdecor; - _GLFWcursor* currentCursor; double cursorPosX, cursorPosY; char* appId; diff --git a/src/wl_window.c b/src/wl_window.c index ee8e4a61b..b00b8cede 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1283,7 +1283,7 @@ static void incrementCursorImage(void) if (window->wl.surface != _glfw.wl.pointerSurface) return; - _GLFWcursor* cursor = window->wl.currentCursor; + _GLFWcursor* cursor = window->cursor; if (cursor && cursor->wl.cursor) { cursor->wl.currentImage += 1; @@ -1543,7 +1543,7 @@ static void pointerHandleEnter(void* userData, _GLFWwindow* window = wl_surface_get_user_data(surface); if (window->wl.surface == surface) { - _glfwSetCursorWayland(window, window->wl.currentCursor); + _glfwSetCursorWayland(window, window->cursor); _glfwInputCursorEnter(window, GLFW_TRUE); if (window->cursorMode != GLFW_CURSOR_DISABLED) @@ -2736,7 +2736,7 @@ void _glfwSetCursorPosWayland(_GLFWwindow* window, double x, double y) void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode) { - _glfwSetCursorWayland(window, window->wl.currentCursor); + _glfwSetCursorWayland(window, window->cursor); } const char* _glfwGetScancodeNameWayland(int scancode) @@ -3070,8 +3070,6 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor) if (!_glfw.wl.pointer) return; - window->wl.currentCursor = cursor; - if (window->wl.surface != _glfw.wl.pointerSurface) return; From c4684b288dc2e43030f26ffc00ef50b25440dd37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 13 Feb 2026 13:24:09 +0100 Subject: [PATCH 072/112] Remove some pointless comments --- src/egl_context.c | 6 ------ src/glx_context.c | 6 ------ src/nsgl_context.m | 6 ------ src/wgl_context.c | 6 ------ 4 files changed, 24 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index 921d5c6eb..46b098f5c 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -358,8 +358,6 @@ static void destroyContextEGL(_GLFWwindow* window) ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// -// Initialize EGL -// GLFWbool _glfwInitEGL(void) { int i; @@ -545,8 +543,6 @@ GLFWbool _glfwInitEGL(void) return GLFW_TRUE; } -// Terminate EGL -// void _glfwTerminateEGL(void) { if (_glfw.egl.display) @@ -570,8 +566,6 @@ void _glfwTerminateEGL(void) attribs[index++] = v; \ } -// Create the OpenGL or OpenGL ES context -// GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) diff --git a/src/glx_context.c b/src/glx_context.c index 098c4bade..84fca9ddd 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -253,8 +253,6 @@ static void destroyContextGLX(_GLFWwindow* window) ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// -// Initialize GLX -// GLFWbool _glfwInitGLX(void) { const char* sonames[] = @@ -426,8 +424,6 @@ GLFWbool _glfwInitGLX(void) return GLFW_TRUE; } -// Terminate GLX -// void _glfwTerminateGLX(void) { // NOTE: This function must not call any X11 functions, as it is called @@ -447,8 +443,6 @@ void _glfwTerminateGLX(void) attribs[index++] = v; \ } -// Create the OpenGL or OpenGL ES context -// GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) diff --git a/src/nsgl_context.m b/src/nsgl_context.m index df7298000..cc676171e 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -128,8 +128,6 @@ static void destroyContextNSGL(_GLFWwindow* window) ////// GLFW internal API ////// ////////////////////////////////////////////////////////////////////////// -// Initialize OpenGL support -// GLFWbool _glfwInitNSGL(void) { if (_glfw.nsgl.framework) @@ -147,14 +145,10 @@ GLFWbool _glfwInitNSGL(void) return GLFW_TRUE; } -// Terminate OpenGL support -// void _glfwTerminateNSGL(void) { } -// Create the OpenGL context -// GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) diff --git a/src/wgl_context.c b/src/wgl_context.c index 3c7d71c23..04429066c 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -401,8 +401,6 @@ static void destroyContextWGL(_GLFWwindow* window) } } -// Initialize WGL -// GLFWbool _glfwInitWGL(void) { PIXELFORMATDESCRIPTOR pfd; @@ -521,8 +519,6 @@ GLFWbool _glfwInitWGL(void) return GLFW_TRUE; } -// Terminate WGL -// void _glfwTerminateWGL(void) { if (_glfw.wgl.instance) @@ -536,8 +532,6 @@ void _glfwTerminateWGL(void) attribs[index++] = v; \ } -// Create the OpenGL or OpenGL ES context -// GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig) From a98badf088284a29c5adbb9d2376d6e5935b5c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 9 Feb 2026 19:48:45 +0100 Subject: [PATCH 073/112] Wayland: Fix key repeat on very old compositors The client-side key repeat timer fd was only created for wl_seat version 4 or later, but was then used unconditionally during event processing. Rather than have this mechanism do nothing in a more correct way on wl_seat version 3 or earlier (which is very old by now), this commit creates the key repeat timer fd and then sets (hopefully gentle) hardcoded repeat delay and rate. --- README.md | 1 + src/wl_init.c | 17 ++++++++++------- src/wl_window.c | 7 +++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b05132e7b..a5689a5ca 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ information on what to include when reporting a bug. potential segmentation fault (#2744) - [Wayland] Bugfix: Confining or disabling the cursor could segfault on compositors without `pointer-constraints-unstable-v1` + - [Wayland] Bugfix: Key repeat did not function on very old compositors - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/wl_init.c b/src/wl_init.c index 1d0d3ef82..41cbc57c4 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -137,13 +137,6 @@ 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) @@ -834,6 +827,16 @@ int _glfwInitWayland(void) createKeyTables(); + _glfw.wl.keyRepeatTimerfd = + timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK); + if (_glfw.wl.keyRepeatTimerfd == -1) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create timerfd: %s", + strerror(errno)); + return GLFW_FALSE; + } + _glfw.wl.xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); if (!_glfw.wl.xkb.context) { diff --git a/src/wl_window.c b/src/wl_window.c index b00b8cede..1efb7256d 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1942,6 +1942,13 @@ static void seatHandleCapabilities(void* userData, { _glfw.wl.keyboard = wl_seat_get_keyboard(seat); wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL); + + if (wl_keyboard_get_version(_glfw.wl.keyboard) < + WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) + { + _glfw.wl.keyRepeatRate = 4; + _glfw.wl.keyRepeatDelay = 500; + } } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard) { From a3095e1aa594062616a1bfc76005011d8123d377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 5 Feb 2026 22:29:50 +0100 Subject: [PATCH 074/112] X11: Fix libXext not unloaded at termination --- README.md | 1 + src/x11_init.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index a5689a5ca..29bd91f76 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,7 @@ information on what to include when reporting a bug. less than 1 (#2754) - [X11] Bugfix: Clamp width and height to >= 1 to prevent BadValue error and app exit - [X11] Bugfix: Floating windows silently became non-floating when hidden (#2276) + - [X11] Bugfix: The `libXext` library was not unloaded at termination - [Linux] Bugfix: The header for `ioctl` was only implicitly included (#2778) - [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/x11_init.c b/src/x11_init.c index 6b34c2639..5f760f432 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1622,6 +1622,12 @@ void _glfwTerminateX11(void) _glfw.x11.xrender.handle = NULL; } + if (_glfw.x11.xshape.handle) + { + _glfwPlatformFreeModule(_glfw.x11.xshape.handle); + _glfw.x11.xshape.handle = NULL; + } + if (_glfw.x11.vidmode.handle) { _glfwPlatformFreeModule(_glfw.x11.vidmode.handle); From b579ea6792fe882394bf6cb615397d15db29a945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 5 Feb 2026 22:30:20 +0100 Subject: [PATCH 075/112] Wayland: Fix libwayland-client not unloaded --- README.md | 1 + src/wl_init.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 29bd91f76..518d31cb5 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Confining or disabling the cursor could segfault on compositors without `pointer-constraints-unstable-v1` - [Wayland] Bugfix: Key repeat did not function on very old compositors + - [Wayland] Bugfix: The `libwayland-client` library was not unloaded at termination - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/wl_init.c b/src/wl_init.c index 41cbc57c4..025f77464 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1014,6 +1014,12 @@ void _glfwTerminateWayland(void) _glfw.wl.cursor.handle = NULL; } + if (_glfw.wl.client.handle) + { + _glfwPlatformFreeModule(_glfw.wl.client.handle); + _glfw.wl.client.handle = NULL; + } + _glfw_free(_glfw.wl.clipboardString); } From f0b2992b3ae579f808f3fc2ede5292d009e60b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 4 Dec 2025 15:33:24 +0100 Subject: [PATCH 076/112] Allow NULL argument to _glfwPlatformFreeModule This matches the behavior of _glfw_free and the public API, simplifying cleanup code. --- src/cocoa_init.m | 2 ++ src/egl_context.c | 9 +++---- src/glx_context.c | 7 ++--- src/null_init.c | 1 + src/osmesa_context.c | 7 ++--- src/posix_module.c | 3 ++- src/vulkan.c | 4 +-- src/wgl_context.c | 4 +-- src/win32_init.c | 32 ++++++---------------- src/win32_module.c | 3 ++- src/wl_init.c | 43 ++++++----------------------- src/x11_init.c | 64 ++++++++------------------------------------ 12 files changed, 45 insertions(+), 134 deletions(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 15dc4ec4c..531d8b452 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -688,6 +688,8 @@ void _glfwTerminateCocoa(void) _glfwTerminateEGL(); _glfwTerminateOSMesa(); + memset(&_glfw.ns, 0, sizeof(_glfw.ns)); + } // autoreleasepool } diff --git a/src/egl_context.c b/src/egl_context.c index 46b098f5c..4e59d78bf 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -333,11 +333,8 @@ static void destroyContextEGL(_GLFWwindow* window) if (_glfw.platform.platformID != GLFW_PLATFORM_X11 || window->context.client != GLFW_OPENGL_API) { - if (window->context.egl.client) - { - _glfwPlatformFreeModule(window->context.egl.client); - window->context.egl.client = NULL; - } + _glfwPlatformFreeModule(window->context.egl.client); + window->context.egl.client = NULL; } if (window->context.egl.surface) @@ -552,7 +549,7 @@ void _glfwTerminateEGL(void) } // Free modules only after all wayland termination functions are called - if (_glfw.egl.handle && _glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) + if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) { _glfwPlatformFreeModule(_glfw.egl.handle); _glfw.egl.handle = NULL; diff --git a/src/glx_context.c b/src/glx_context.c index 84fca9ddd..f08cdd5b8 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -429,11 +429,8 @@ void _glfwTerminateGLX(void) // NOTE: This function must not call any X11 functions, as it is called // after XCloseDisplay (see _glfwTerminateX11 for details) - if (_glfw.glx.handle) - { - _glfwPlatformFreeModule(_glfw.glx.handle); - _glfw.glx.handle = NULL; - } + _glfwPlatformFreeModule(_glfw.glx.handle); + _glfw.glx.handle = NULL; } #define SET_ATTRIB(a, v) \ diff --git a/src/null_init.c b/src/null_init.c index 8c10f5e67..fd0d9e969 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -260,5 +260,6 @@ void _glfwTerminateNull(void) free(_glfw.null.clipboardString); _glfwTerminateOSMesa(); _glfwTerminateEGL(); + memset(&_glfw.null, 0, sizeof(_glfw.null)); } diff --git a/src/osmesa_context.c b/src/osmesa_context.c index 0bb375a8b..c7a4c8686 100644 --- a/src/osmesa_context.c +++ b/src/osmesa_context.c @@ -180,11 +180,8 @@ GLFWbool _glfwInitOSMesa(void) void _glfwTerminateOSMesa(void) { - if (_glfw.osmesa.handle) - { - _glfwPlatformFreeModule(_glfw.osmesa.handle); - _glfw.osmesa.handle = NULL; - } + _glfwPlatformFreeModule(_glfw.osmesa.handle); + _glfw.osmesa.handle = NULL; } #define SET_ATTRIB(a, v) \ diff --git a/src/posix_module.c b/src/posix_module.c index b3482d26c..de99bc691 100644 --- a/src/posix_module.c +++ b/src/posix_module.c @@ -41,7 +41,8 @@ void* _glfwPlatformLoadModule(const char* path) void _glfwPlatformFreeModule(void* module) { - dlclose(module); + if (module) + dlclose(module); } GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) diff --git a/src/vulkan.c b/src/vulkan.c index 9c87fcfe1..8f25f5ee9 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -157,8 +157,8 @@ GLFWbool _glfwInitVulkan(int mode) void _glfwTerminateVulkan(void) { - if (_glfw.vk.handle) - _glfwPlatformFreeModule(_glfw.vk.handle); + _glfwPlatformFreeModule(_glfw.vk.handle); + _glfw.vk.handle = NULL; } const char* _glfwGetVulkanResultString(VkResult result) diff --git a/src/wgl_context.c b/src/wgl_context.c index 04429066c..1fb7d322e 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -521,8 +521,8 @@ GLFWbool _glfwInitWGL(void) void _glfwTerminateWGL(void) { - if (_glfw.wgl.instance) - _glfwPlatformFreeModule(_glfw.wgl.instance); + _glfwPlatformFreeModule(_glfw.wgl.instance); + _glfw.wgl.instance = NULL; } #define SET_ATTRIB(a, v) \ diff --git a/src/win32_init.c b/src/win32_init.c index 90e47670e..d526fe8a3 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -166,29 +166,6 @@ static GLFWbool loadLibraries(void) return GLFW_TRUE; } -// Unload used libraries (DLLs) -// -static void freeLibraries(void) -{ - if (_glfw.win32.xinput.instance) - _glfwPlatformFreeModule(_glfw.win32.xinput.instance); - - if (_glfw.win32.dinput8.instance) - _glfwPlatformFreeModule(_glfw.win32.dinput8.instance); - - if (_glfw.win32.user32.instance) - _glfwPlatformFreeModule(_glfw.win32.user32.instance); - - if (_glfw.win32.dwmapi.instance) - _glfwPlatformFreeModule(_glfw.win32.dwmapi.instance); - - if (_glfw.win32.shcore.instance) - _glfwPlatformFreeModule(_glfw.win32.shcore.instance); - - if (_glfw.win32.ntdll.instance) - _glfwPlatformFreeModule(_glfw.win32.ntdll.instance); -} - // Create key code translation tables // static void createKeyTables(void) @@ -721,7 +698,14 @@ void _glfwTerminateWin32(void) _glfwTerminateEGL(); _glfwTerminateOSMesa(); - freeLibraries(); + _glfwPlatformFreeModule(_glfw.win32.xinput.instance); + _glfwPlatformFreeModule(_glfw.win32.dinput8.instance); + _glfwPlatformFreeModule(_glfw.win32.user32.instance); + _glfwPlatformFreeModule(_glfw.win32.dwmapi.instance); + _glfwPlatformFreeModule(_glfw.win32.shcore.instance); + _glfwPlatformFreeModule(_glfw.win32.ntdll.instance); + + memset(&_glfw.win32, 0, sizeof(_glfw.win32)); } #endif // _GLFW_WIN32 diff --git a/src/win32_module.c b/src/win32_module.c index b76599b61..ca5ce9cfa 100644 --- a/src/win32_module.c +++ b/src/win32_module.c @@ -39,7 +39,8 @@ void* _glfwPlatformLoadModule(const char* path) void _glfwPlatformFreeModule(void* module) { - FreeLibrary((HMODULE) module); + if (module) + FreeLibrary((HMODULE) module); } GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name) diff --git a/src/wl_init.c b/src/wl_init.c index 025f77464..b2fd6a888 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -984,43 +984,16 @@ void _glfwTerminateWayland(void) // Free modules only after all Wayland termination functions are called - if (_glfw.egl.handle) - { - _glfwPlatformFreeModule(_glfw.egl.handle); - _glfw.egl.handle = NULL; - } - - if (_glfw.wl.libdecor.handle) - { - _glfwPlatformFreeModule(_glfw.wl.libdecor.handle); - _glfw.wl.libdecor.handle = NULL; - } - - if (_glfw.wl.egl.handle) - { - _glfwPlatformFreeModule(_glfw.wl.egl.handle); - _glfw.wl.egl.handle = NULL; - } - - if (_glfw.wl.xkb.handle) - { - _glfwPlatformFreeModule(_glfw.wl.xkb.handle); - _glfw.wl.xkb.handle = NULL; - } - - if (_glfw.wl.cursor.handle) - { - _glfwPlatformFreeModule(_glfw.wl.cursor.handle); - _glfw.wl.cursor.handle = NULL; - } - - if (_glfw.wl.client.handle) - { - _glfwPlatformFreeModule(_glfw.wl.client.handle); - _glfw.wl.client.handle = NULL; - } + _glfwPlatformFreeModule(_glfw.egl.handle); + _glfwPlatformFreeModule(_glfw.wl.libdecor.handle); + _glfwPlatformFreeModule(_glfw.wl.egl.handle); + _glfwPlatformFreeModule(_glfw.wl.xkb.handle); + _glfwPlatformFreeModule(_glfw.wl.cursor.handle); + _glfwPlatformFreeModule(_glfw.wl.client.handle); _glfw_free(_glfw.wl.clipboardString); + + memset(&_glfw.wl, 0, sizeof(_glfw.wl)); } #endif // _GLFW_WAYLAND diff --git a/src/x11_init.c b/src/x11_init.c index 5f760f432..b0acbf7f6 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1592,71 +1592,29 @@ void _glfwTerminateX11(void) _glfw.x11.display = NULL; } - if (_glfw.x11.x11xcb.handle) - { - _glfwPlatformFreeModule(_glfw.x11.x11xcb.handle); - _glfw.x11.x11xcb.handle = NULL; - } - - if (_glfw.x11.xcursor.handle) - { - _glfwPlatformFreeModule(_glfw.x11.xcursor.handle); - _glfw.x11.xcursor.handle = NULL; - } - - if (_glfw.x11.randr.handle) - { - _glfwPlatformFreeModule(_glfw.x11.randr.handle); - _glfw.x11.randr.handle = NULL; - } - - if (_glfw.x11.xinerama.handle) - { - _glfwPlatformFreeModule(_glfw.x11.xinerama.handle); - _glfw.x11.xinerama.handle = NULL; - } - - if (_glfw.x11.xrender.handle) - { - _glfwPlatformFreeModule(_glfw.x11.xrender.handle); - _glfw.x11.xrender.handle = NULL; - } - - if (_glfw.x11.xshape.handle) - { - _glfwPlatformFreeModule(_glfw.x11.xshape.handle); - _glfw.x11.xshape.handle = NULL; - } - - if (_glfw.x11.vidmode.handle) - { - _glfwPlatformFreeModule(_glfw.x11.vidmode.handle); - _glfw.x11.vidmode.handle = NULL; - } - - if (_glfw.x11.xi.handle) - { - _glfwPlatformFreeModule(_glfw.x11.xi.handle); - _glfw.x11.xi.handle = NULL; - } - _glfwTerminateOSMesa(); // NOTE: These need to be unloaded after XCloseDisplay, as they register // cleanup callbacks that get called by that function _glfwTerminateEGL(); _glfwTerminateGLX(); - if (_glfw.x11.xlib.handle) - { - _glfwPlatformFreeModule(_glfw.x11.xlib.handle); - _glfw.x11.xlib.handle = NULL; - } + _glfwPlatformFreeModule(_glfw.x11.x11xcb.handle); + _glfwPlatformFreeModule(_glfw.x11.xcursor.handle); + _glfwPlatformFreeModule(_glfw.x11.randr.handle); + _glfwPlatformFreeModule(_glfw.x11.xinerama.handle); + _glfwPlatformFreeModule(_glfw.x11.xrender.handle); + _glfwPlatformFreeModule(_glfw.x11.xshape.handle); + _glfwPlatformFreeModule(_glfw.x11.vidmode.handle); + _glfwPlatformFreeModule(_glfw.x11.xi.handle); + _glfwPlatformFreeModule(_glfw.x11.xlib.handle); if (_glfw.x11.emptyEventPipe[0] || _glfw.x11.emptyEventPipe[1]) { close(_glfw.x11.emptyEventPipe[0]); close(_glfw.x11.emptyEventPipe[1]); } + + memset(&_glfw.x11, 0, sizeof(_glfw.x11)); } #endif // _GLFW_X11 From 3f14b6feed2b66a70c08e73d5e17afa659b55648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 12 Feb 2026 16:04:00 +0100 Subject: [PATCH 077/112] EGL: Try eglGetProcAddress before fallback method This order matches what is done for every other context creation API that has a similar fallback method. --- src/egl_context.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index 4e59d78bf..9aec5a2ae 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -312,18 +312,19 @@ static int extensionSupportedEGL(const char* extension) static GLFWglproc getProcAddressEGL(const char* procname) { - _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); - assert(window != NULL); + const GLFWglproc proc = (GLFWglproc) eglGetProcAddress(procname); + if (proc) + return proc; - if (window->context.egl.client) + if (!_glfw.egl.KHR_get_all_proc_addresses) { - GLFWglproc proc = (GLFWglproc) - _glfwPlatformGetModuleSymbol(window->context.egl.client, procname); - if (proc) - return proc; + _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + assert(window != NULL); + + return _glfwPlatformGetModuleSymbol(window->context.egl.client, procname); } - return eglGetProcAddress(procname); + return NULL; } static void destroyContextEGL(_GLFWwindow* window) From 001f94eaa7b47d84cb64d721fbd24ab4cc44ef4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 1 Sep 2025 17:13:05 +0200 Subject: [PATCH 078/112] Wayland: Add support for pointer event frames This adds support for wl_seat version 5, which adds pointer frames. This allows two-dimensional scroll input to be emitted as single events instead of one event per axis per motion. It's also the the foundation for future enhancements like properly scaled discrete scroll events and server-side key repeat. Fixes #2494 --- CONTRIBUTORS.md | 1 + README.md | 2 + src/wl_init.c | 2 +- src/wl_platform.h | 14 ++- src/wl_window.c | 268 ++++++++++++++++++++++++++++++++++++---------- 5 files changed, 230 insertions(+), 57 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 031962ecd..7a544eb61 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -79,6 +79,7 @@ video tutorials. - Jason Francis - Gerald Franz - Mário Freitas + - Friz64 - GeO4d - Marcus Geelnard - Gegy diff --git a/README.md b/README.md index 518d31cb5..ab346ae65 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,8 @@ information on what to include when reporting a bug. compositors without `pointer-constraints-unstable-v1` - [Wayland] Bugfix: Key repeat did not function on very old compositors - [Wayland] Bugfix: The `libwayland-client` library was not unloaded at termination + - [Wayland] Bugfix: Scroll events were sent twice on some versions of GNOME (#2494) + - [Wayland] Bugfix: Two-dimensional scroll input was emitted as separate axes - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/wl_init.c b/src/wl_init.c index b2fd6a888..1e5276490 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -135,7 +135,7 @@ static void registryHandleGlobal(void* userData, { _glfw.wl.seat = wl_registry_bind(registry, name, &wl_seat_interface, - _glfw_min(4, version)); + _glfw_min(5, version)); _glfwAddSeatListenerWayland(_glfw.wl.seat); } } diff --git a/src/wl_platform.h b/src/wl_platform.h index c2ddb732c..c9d1c2512 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -414,7 +414,8 @@ typedef struct _GLFWwindowWayland GLFWbool decorations; struct wl_buffer* buffer; _GLFWfallbackEdgeWayland top, left, right, bottom; - wl_fixed_t pointerX, pointerY; + double pointerX, pointerY; + uint32_t buttonPressSerial; const char* cursorName; } fallback; } _GLFWwindowWayland; @@ -472,6 +473,17 @@ typedef struct _GLFWlibraryWayland short int scancodes[GLFW_KEY_LAST + 1]; char keynames[GLFW_KEY_LAST + 1][5]; + struct { + struct wl_surface* pointerSurface; + unsigned int events; + double pointerX; + double pointerY; + double scrollX; + double scrollY; + int button; + int action; + } pending; + struct { void* handle; struct xkb_context* context; diff --git a/src/wl_window.c b/src/wl_window.c index 1efb7256d..f089f2432 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -55,6 +55,11 @@ #define GLFW_BORDER_SIZE 4 #define GLFW_CAPTION_HEIGHT 24 +#define GLFW_PENDING_SURFACE 1 +#define GLFW_PENDING_BUTTON 2 +#define GLFW_PENDING_MOTION 4 +#define GLFW_PENDING_SCROLL 8 + static int createTmpfileCloexec(char* tmpname) { int fd; @@ -278,15 +283,11 @@ static void destroyFallbackDecorations(_GLFWwindow* window) destroyFallbackEdge(&window->wl.fallback.bottom); } -static void updateFallbackDecorationCursor(_GLFWwindow* window, - wl_fixed_t sx, - wl_fixed_t sy) +static void updateFallbackDecorationCursor(_GLFWwindow* window, double xpos, double ypos) { - window->wl.fallback.pointerX = sx; - window->wl.fallback.pointerY = sy; + window->wl.fallback.pointerX = xpos; + window->wl.fallback.pointerY = ypos; - const double xpos = wl_fixed_to_double(sx); - const double ypos = wl_fixed_to_double(sy); const char* cursorName = "left_ptr"; if (window->resizable) @@ -361,18 +362,16 @@ static void updateFallbackDecorationCursor(_GLFWwindow* window, } } -static void handleFallbackDecorationButton(_GLFWwindow* window, - uint32_t serial, - uint32_t button, - uint32_t state) +static void handleFallbackDecorationButton(_GLFWwindow* window, int button, int action) { - if (state != WL_POINTER_BUTTON_STATE_PRESSED) + if (action != GLFW_PRESS) return; - const double xpos = wl_fixed_to_double(window->wl.fallback.pointerX); - const double ypos = wl_fixed_to_double(window->wl.fallback.pointerY); + const double xpos = window->wl.fallback.pointerX; + const double ypos = window->wl.fallback.pointerY; + const uint32_t serial = window->wl.fallback.buttonPressSerial; - if (button == BTN_LEFT) + if (button == GLFW_MOUSE_BUTTON_LEFT) { uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE; @@ -410,7 +409,7 @@ static void handleFallbackDecorationButton(_GLFWwindow* window, if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE) xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, serial, edges); } - else if (button == BTN_RIGHT) + else if (button == GLFW_MOUSE_BUTTON_RIGHT) { if (!window->wl.xdg.toplevel) return; @@ -421,10 +420,8 @@ static void handleFallbackDecorationButton(_GLFWwindow* window, if (ypos < GLFW_BORDER_SIZE) return; - xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, - _glfw.wl.seat, serial, - xpos, - ypos - GLFW_CAPTION_HEIGHT - GLFW_BORDER_SIZE); + xdg_toplevel_show_window_menu(window->wl.xdg.toplevel, _glfw.wl.seat, serial, + xpos, ypos - GLFW_CAPTION_HEIGHT - GLFW_BORDER_SIZE); } } @@ -1538,25 +1535,39 @@ static void pointerHandleEnter(void* userData, _glfw.wl.serial = serial; _glfw.wl.pointerEnterSerial = serial; - _glfw.wl.pointerSurface = surface; _GLFWwindow* window = wl_surface_get_user_data(surface); - if (window->wl.surface == surface) - { - _glfwSetCursorWayland(window, window->cursor); - _glfwInputCursorEnter(window, GLFW_TRUE); + const double xpos = wl_fixed_to_double(sx); + const double ypos = wl_fixed_to_double(sy); - if (window->cursorMode != GLFW_CURSOR_DISABLED) - { - window->wl.cursorPosX = wl_fixed_to_double(sx); - window->wl.cursorPosY = wl_fixed_to_double(sy); - _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); - } + if (wl_pointer_get_version(pointer) >= WL_POINTER_FRAME_SINCE_VERSION) + { + _glfw.wl.pending.events |= (GLFW_PENDING_SURFACE | GLFW_PENDING_MOTION); + _glfw.wl.pending.pointerSurface = surface; + _glfw.wl.pending.pointerX = xpos; + _glfw.wl.pending.pointerY = ypos; } else { - if (window->wl.fallback.decorations) - updateFallbackDecorationCursor(window, sx, sy); + _glfw.wl.pointerSurface = surface; + + if (window->wl.surface == _glfw.wl.pointerSurface) + { + _glfwSetCursorWayland(window, window->cursor); + _glfwInputCursorEnter(window, GLFW_TRUE); + + if (window->cursorMode != GLFW_CURSOR_DISABLED) + { + window->wl.cursorPosX = xpos; + window->wl.cursorPosY = ypos; + _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); + } + } + else + { + if (window->wl.fallback.decorations) + updateFallbackDecorationCursor(window, xpos, ypos); + } } } @@ -1572,15 +1583,25 @@ static void pointerHandleLeave(void* userData, return; _glfw.wl.serial = serial; - _glfw.wl.pointerSurface = NULL; _GLFWwindow* window = wl_surface_get_user_data(surface); - if (window->wl.surface == surface) - _glfwInputCursorEnter(window, GLFW_FALSE); + + if (wl_pointer_get_version(pointer) >= WL_POINTER_FRAME_SINCE_VERSION) + { + _glfw.wl.pending.events |= GLFW_PENDING_SURFACE; + _glfw.wl.pending.pointerSurface = NULL; + } else { - if (window->wl.fallback.decorations) - window->wl.fallback.cursorName = NULL; + _glfw.wl.pointerSurface = NULL; + + if (window->wl.surface == surface) + _glfwInputCursorEnter(window, GLFW_FALSE); + else + { + if (window->wl.fallback.decorations) + window->wl.fallback.cursorName = NULL; + } } } @@ -1594,20 +1615,28 @@ static void pointerHandleMotion(void* userData, return; _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); - if (window->cursorMode == GLFW_CURSOR_DISABLED) return; - if (window->wl.surface == _glfw.wl.pointerSurface) + const double xpos = wl_fixed_to_double(sx); + const double ypos = wl_fixed_to_double(sy); + + if (wl_pointer_get_version(pointer) >= WL_POINTER_FRAME_SINCE_VERSION) { - window->wl.cursorPosX = wl_fixed_to_double(sx); - window->wl.cursorPosY = wl_fixed_to_double(sy); - _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); + _glfw.wl.pending.events |= GLFW_PENDING_MOTION; + _glfw.wl.pending.pointerX = xpos; + _glfw.wl.pending.pointerY = ypos; } else { - if (window->wl.fallback.decorations) - updateFallbackDecorationCursor(window, sx, sy); + if (window->wl.surface == _glfw.wl.pointerSurface) + { + window->wl.cursorPosX = xpos; + window->wl.cursorPosY = ypos; + _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); + } + else + updateFallbackDecorationCursor(window, xpos, ypos); } } @@ -1615,27 +1644,39 @@ static void pointerHandleButton(void* userData, struct wl_pointer* pointer, uint32_t serial, uint32_t time, - uint32_t button, + uint32_t buttonID, uint32_t state) { if (!_glfw.wl.pointerSurface) return; + _glfw.wl.serial = serial; + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + const int button = buttonID - BTN_LEFT; + const int action = (state == WL_POINTER_BUTTON_STATE_PRESSED); - if (window->wl.surface == _glfw.wl.pointerSurface) + if (window->wl.fallback.decorations) { - _glfw.wl.serial = serial; + if (action == GLFW_PRESS) + window->wl.fallback.buttonPressSerial = serial; + } - _glfwInputMouseClick(window, - button - BTN_LEFT, - state == WL_POINTER_BUTTON_STATE_PRESSED, - _glfw.wl.xkb.modifiers); + if (wl_pointer_get_version(pointer) >= WL_POINTER_FRAME_SINCE_VERSION) + { + _glfw.wl.pending.events |= GLFW_PENDING_BUTTON; + _glfw.wl.pending.button = button; + _glfw.wl.pending.action = action; } else { - if (window->wl.fallback.decorations) - handleFallbackDecorationButton(window, serial, button, state); + if (window->wl.surface == _glfw.wl.pointerSurface) + _glfwInputMouseClick(window, button, action, _glfw.wl.xkb.modifiers); + else + { + if (window->wl.fallback.decorations) + handleFallbackDecorationButton(window, button, action); + } } } @@ -1649,8 +1690,18 @@ static void pointerHandleAxis(void* userData, return; _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + if (window->wl.surface != _glfw.wl.pointerSurface) + return; - if (window->wl.surface == _glfw.wl.pointerSurface) + if (wl_pointer_get_version(pointer) >= WL_POINTER_FRAME_SINCE_VERSION) + { + _glfw.wl.pending.events |= GLFW_PENDING_SCROLL; + if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) + _glfw.wl.pending.scrollX = -wl_fixed_to_double(value) / 10.0; + else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) + _glfw.wl.pending.scrollY = -wl_fixed_to_double(value) / 10.0; + } + else { // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) @@ -1660,6 +1711,109 @@ static void pointerHandleAxis(void* userData, } } +static void pointerHandleFrame(void* userData, struct wl_pointer* pointer) +{ + if (_glfw.wl.pending.events & GLFW_PENDING_SURFACE) + { + if (_glfw.wl.pointerSurface) + { + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + if (window->wl.surface == _glfw.wl.pointerSurface) + _glfwInputCursorEnter(window, GLFW_FALSE); + else + { + if (window->wl.fallback.decorations) + window->wl.fallback.cursorName = NULL; + } + } + + _glfw.wl.pointerSurface = _glfw.wl.pending.pointerSurface; + + if (_glfw.wl.pointerSurface) + { + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + if (window->wl.surface == _glfw.wl.pointerSurface) + { + _glfwSetCursorWayland(window, window->cursor); + _glfwInputCursorEnter(window, GLFW_TRUE); + } + } + } + + if (!_glfw.wl.pointerSurface) + return; + + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + + if (_glfw.wl.pending.events & GLFW_PENDING_MOTION) + { + if (window->wl.surface == _glfw.wl.pointerSurface) + { + window->wl.cursorPosX = _glfw.wl.pending.pointerX; + window->wl.cursorPosY = _glfw.wl.pending.pointerY; + _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); + } + else + { + updateFallbackDecorationCursor(window, + _glfw.wl.pending.pointerX, + _glfw.wl.pending.pointerY); + } + } + + if (_glfw.wl.pending.events & GLFW_PENDING_BUTTON) + { + if (window->wl.surface == _glfw.wl.pointerSurface) + { + _glfwInputMouseClick(window, + _glfw.wl.pending.button, + _glfw.wl.pending.action, + _glfw.wl.xkb.modifiers); + } + else + { + if (window->wl.fallback.decorations) + { + handleFallbackDecorationButton(window, + _glfw.wl.pending.button, + _glfw.wl.pending.action); + } + } + } + + if (_glfw.wl.pending.events & GLFW_PENDING_SCROLL) + { + if (window->wl.surface == _glfw.wl.pointerSurface) + { + _glfwInputScroll(window, + _glfw.wl.pending.scrollX, + _glfw.wl.pending.scrollY); + } + } + + memset(&_glfw.wl.pending, 0, sizeof(_glfw.wl.pending)); +} + +static void pointerHandleAxisSource(void* userData, + struct wl_pointer* pointer, + uint32_t axisSource) +{ +} + +static void pointerHandleAxisStop(void* userData, + struct wl_pointer* pointer, + uint32_t time, + uint32_t axis) +{ +} + +static void pointerHandleAxisDiscrete(void* userData, + struct wl_pointer* pointer, + uint32_t axis, + int32_t discrete) +{ +} + static const struct wl_pointer_listener pointerListener = { pointerHandleEnter, @@ -1667,6 +1821,10 @@ static const struct wl_pointer_listener pointerListener = pointerHandleMotion, pointerHandleButton, pointerHandleAxis, + pointerHandleFrame, + pointerHandleAxisSource, + pointerHandleAxisStop, + pointerHandleAxisDiscrete }; static void keyboardHandleKeymap(void* userData, From 99cdcfb0a4265fab866da889c241c35d800116a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 30 Jan 2026 16:13:58 +0100 Subject: [PATCH 079/112] Wayland: Unify pointer input paths This reduces pointer frame support to a small amount of plumbing. --- src/wl_window.c | 204 ++++++++++++++++++------------------------------ 1 file changed, 78 insertions(+), 126 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index f089f2432..dd097cf9f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1519,6 +1519,70 @@ static char* readDataOfferAsString(struct wl_data_offer* offer, const char* mime return string; } +static void processPointerEnterSurface(struct wl_surface* surface) +{ + _glfw.wl.pointerSurface = surface; + + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + if (window->wl.surface == _glfw.wl.pointerSurface) + { + _glfwSetCursorWayland(window, window->cursor); + _glfwInputCursorEnter(window, GLFW_TRUE); + } +} + +static void processPointerLeaveSurface(struct wl_surface* surface) +{ + _glfw.wl.pointerSurface = NULL; + + _GLFWwindow* window = wl_surface_get_user_data(surface); + if (window->wl.surface == surface) + _glfwInputCursorEnter(window, GLFW_FALSE); + else + { + if (window->wl.fallback.decorations) + window->wl.fallback.cursorName = NULL; + } +} + +static void processPointerMotion(double xpos, double ypos) +{ + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + if (window->wl.surface == _glfw.wl.pointerSurface) + { + if (window->cursorMode != GLFW_CURSOR_DISABLED) + { + window->wl.cursorPosX = xpos; + window->wl.cursorPosY = ypos; + _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); + } + } + else + { + if (window->wl.fallback.decorations) + updateFallbackDecorationCursor(window, xpos, ypos); + } +} + +static void processPointerButton(int button, int action) +{ + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + if (window->wl.surface == _glfw.wl.pointerSurface) + _glfwInputMouseClick(window, button, action, _glfw.wl.xkb.modifiers); + else + { + if (window->wl.fallback.decorations) + handleFallbackDecorationButton(window, button, action); + } +} + +static void processPointerScroll(double xoffset, double yoffset) +{ + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); + if (window->wl.surface == _glfw.wl.pointerSurface) + _glfwInputScroll(window, xoffset, yoffset); +} + static void pointerHandleEnter(void* userData, struct wl_pointer* pointer, uint32_t serial, @@ -1536,7 +1600,6 @@ static void pointerHandleEnter(void* userData, _glfw.wl.serial = serial; _glfw.wl.pointerEnterSerial = serial; - _GLFWwindow* window = wl_surface_get_user_data(surface); const double xpos = wl_fixed_to_double(sx); const double ypos = wl_fixed_to_double(sy); @@ -1549,25 +1612,8 @@ static void pointerHandleEnter(void* userData, } else { - _glfw.wl.pointerSurface = surface; - - if (window->wl.surface == _glfw.wl.pointerSurface) - { - _glfwSetCursorWayland(window, window->cursor); - _glfwInputCursorEnter(window, GLFW_TRUE); - - if (window->cursorMode != GLFW_CURSOR_DISABLED) - { - window->wl.cursorPosX = xpos; - window->wl.cursorPosY = ypos; - _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); - } - } - else - { - if (window->wl.fallback.decorations) - updateFallbackDecorationCursor(window, xpos, ypos); - } + processPointerEnterSurface(surface); + processPointerMotion(xpos, ypos); } } @@ -1584,25 +1630,13 @@ static void pointerHandleLeave(void* userData, _glfw.wl.serial = serial; - _GLFWwindow* window = wl_surface_get_user_data(surface); - if (wl_pointer_get_version(pointer) >= WL_POINTER_FRAME_SINCE_VERSION) { _glfw.wl.pending.events |= GLFW_PENDING_SURFACE; _glfw.wl.pending.pointerSurface = NULL; } else - { - _glfw.wl.pointerSurface = NULL; - - if (window->wl.surface == surface) - _glfwInputCursorEnter(window, GLFW_FALSE); - else - { - if (window->wl.fallback.decorations) - window->wl.fallback.cursorName = NULL; - } - } + processPointerLeaveSurface(surface); } static void pointerHandleMotion(void* userData, @@ -1614,10 +1648,6 @@ static void pointerHandleMotion(void* userData, if (!_glfw.wl.pointerSurface) return; - _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); - if (window->cursorMode == GLFW_CURSOR_DISABLED) - return; - const double xpos = wl_fixed_to_double(sx); const double ypos = wl_fixed_to_double(sy); @@ -1628,16 +1658,7 @@ static void pointerHandleMotion(void* userData, _glfw.wl.pending.pointerY = ypos; } else - { - if (window->wl.surface == _glfw.wl.pointerSurface) - { - window->wl.cursorPosX = xpos; - window->wl.cursorPosY = ypos; - _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); - } - else - updateFallbackDecorationCursor(window, xpos, ypos); - } + processPointerMotion(xpos, ypos); } static void pointerHandleButton(void* userData, @@ -1652,10 +1673,10 @@ static void pointerHandleButton(void* userData, _glfw.wl.serial = serial; - _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); const int button = buttonID - BTN_LEFT; const int action = (state == WL_POINTER_BUTTON_STATE_PRESSED); + _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); if (window->wl.fallback.decorations) { if (action == GLFW_PRESS) @@ -1669,15 +1690,7 @@ static void pointerHandleButton(void* userData, _glfw.wl.pending.action = action; } else - { - if (window->wl.surface == _glfw.wl.pointerSurface) - _glfwInputMouseClick(window, button, action, _glfw.wl.xkb.modifiers); - else - { - if (window->wl.fallback.decorations) - handleFallbackDecorationButton(window, button, action); - } - } + processPointerButton(button, action); } static void pointerHandleAxis(void* userData, @@ -1689,10 +1702,6 @@ static void pointerHandleAxis(void* userData, if (!_glfw.wl.pointerSurface) return; - _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); - if (window->wl.surface != _glfw.wl.pointerSurface) - return; - if (wl_pointer_get_version(pointer) >= WL_POINTER_FRAME_SINCE_VERSION) { _glfw.wl.pending.events |= GLFW_PENDING_SCROLL; @@ -1705,9 +1714,9 @@ static void pointerHandleAxis(void* userData, { // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) - _glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0); + processPointerScroll(-wl_fixed_to_double(value) / 10.0, 0.0); else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) - _glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0); + processPointerScroll(0.0, -wl_fixed_to_double(value) / 10.0); } } @@ -1716,80 +1725,23 @@ static void pointerHandleFrame(void* userData, struct wl_pointer* pointer) if (_glfw.wl.pending.events & GLFW_PENDING_SURFACE) { if (_glfw.wl.pointerSurface) - { - _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); - if (window->wl.surface == _glfw.wl.pointerSurface) - _glfwInputCursorEnter(window, GLFW_FALSE); - else - { - if (window->wl.fallback.decorations) - window->wl.fallback.cursorName = NULL; - } - } + processPointerLeaveSurface(_glfw.wl.pointerSurface); - _glfw.wl.pointerSurface = _glfw.wl.pending.pointerSurface; - - if (_glfw.wl.pointerSurface) - { - _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); - if (window->wl.surface == _glfw.wl.pointerSurface) - { - _glfwSetCursorWayland(window, window->cursor); - _glfwInputCursorEnter(window, GLFW_TRUE); - } - } + if (_glfw.wl.pending.pointerSurface) + processPointerEnterSurface(_glfw.wl.pending.pointerSurface); } if (!_glfw.wl.pointerSurface) return; - _GLFWwindow* window = wl_surface_get_user_data(_glfw.wl.pointerSurface); - if (_glfw.wl.pending.events & GLFW_PENDING_MOTION) - { - if (window->wl.surface == _glfw.wl.pointerSurface) - { - window->wl.cursorPosX = _glfw.wl.pending.pointerX; - window->wl.cursorPosY = _glfw.wl.pending.pointerY; - _glfwInputCursorPos(window, window->wl.cursorPosX, window->wl.cursorPosY); - } - else - { - updateFallbackDecorationCursor(window, - _glfw.wl.pending.pointerX, - _glfw.wl.pending.pointerY); - } - } + processPointerMotion(_glfw.wl.pending.pointerX, _glfw.wl.pending.pointerY); if (_glfw.wl.pending.events & GLFW_PENDING_BUTTON) - { - if (window->wl.surface == _glfw.wl.pointerSurface) - { - _glfwInputMouseClick(window, - _glfw.wl.pending.button, - _glfw.wl.pending.action, - _glfw.wl.xkb.modifiers); - } - else - { - if (window->wl.fallback.decorations) - { - handleFallbackDecorationButton(window, - _glfw.wl.pending.button, - _glfw.wl.pending.action); - } - } - } + processPointerButton(_glfw.wl.pending.button, _glfw.wl.pending.action); if (_glfw.wl.pending.events & GLFW_PENDING_SCROLL) - { - if (window->wl.surface == _glfw.wl.pointerSurface) - { - _glfwInputScroll(window, - _glfw.wl.pending.scrollX, - _glfw.wl.pending.scrollY); - } - } + processPointerScroll(_glfw.wl.pending.scrollX, _glfw.wl.pending.scrollY); memset(&_glfw.wl.pending, 0, sizeof(_glfw.wl.pending)); } From abfbf078306ceded825a967e5f582013b3f62d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 13 Feb 2026 15:16:14 +0100 Subject: [PATCH 080/112] Null: Fix dynamic library name selection The name selection for the Vulkan loader and the EGL and client libraries used the GLFW platform macros instead of the platform's own macros. This caused the selection to be incorrect when building only the Null platform on any platform but Linux (where it only accidentally worked due to being the default case). OSMesa was already using the correct method. --- src/egl_context.c | 16 ++++++++-------- src/vulkan.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index 9aec5a2ae..156adb40f 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -365,10 +365,10 @@ GLFWbool _glfwInitEGL(void) { #if defined(_GLFW_EGL_LIBRARY) _GLFW_EGL_LIBRARY, -#elif defined(_GLFW_WIN32) +#elif defined(_WIN32) "libEGL.dll", "EGL.dll", -#elif defined(_GLFW_COCOA) +#elif defined(__APPLE__) "libEGL.dylib", #elif defined(__CYGWIN__) "libEGL-1.so", @@ -761,10 +761,10 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, { #if defined(_GLFW_GLESV1_LIBRARY) _GLFW_GLESV1_LIBRARY, -#elif defined(_GLFW_WIN32) +#elif defined(_WIN32) "GLESv1_CM.dll", "libGLES_CM.dll", -#elif defined(_GLFW_COCOA) +#elif defined(__APPLE__) "libGLESv1_CM.dylib", #elif defined(__OpenBSD__) || defined(__NetBSD__) "libGLESv1_CM.so", @@ -778,10 +778,10 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, { #if defined(_GLFW_GLESV2_LIBRARY) _GLFW_GLESV2_LIBRARY, -#elif defined(_GLFW_WIN32) +#elif defined(_WIN32) "GLESv2.dll", "libGLESv2.dll", -#elif defined(_GLFW_COCOA) +#elif defined(__APPLE__) "libGLESv2.dylib", #elif defined(__CYGWIN__) "libGLESv2-2.so", @@ -796,8 +796,8 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, { #if defined(_GLFW_OPENGL_LIBRARY) _GLFW_OPENGL_LIBRARY, -#elif defined(_GLFW_WIN32) -#elif defined(_GLFW_COCOA) +#elif defined(_WIN32) +#elif defined(__APPLE__) #elif defined(__OpenBSD__) || defined(__NetBSD__) "libGL.so", #else diff --git a/src/vulkan.c b/src/vulkan.c index 8f25f5ee9..f5cc4872b 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -55,9 +55,9 @@ GLFWbool _glfwInitVulkan(int mode) { #if defined(_GLFW_VULKAN_LIBRARY) _glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY); -#elif defined(_GLFW_WIN32) +#elif defined(_WIN32) _glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll"); -#elif defined(_GLFW_COCOA) +#elif defined(__APPLE__) _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); if (!_glfw.vk.handle) _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); From 7c9ea952338b792cb2f70d7c663e498725073797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 13 Feb 2026 15:31:52 +0100 Subject: [PATCH 081/112] Null: Disable Vulkan on macOS for the moment This only affects builds on macOS where only the Null platform is enabled. --- src/vulkan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vulkan.c b/src/vulkan.c index f5cc4872b..b52a57fce 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -57,10 +57,11 @@ GLFWbool _glfwInitVulkan(int mode) _glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY); #elif defined(_WIN32) _glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll"); -#elif defined(__APPLE__) +#elif defined(_GLFW_COCOA) _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); if (!_glfw.vk.handle) _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); +#elif defined(__APPLE__) #elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so"); #else From 3d89365fdb7449487993515156cf81011dc6121c Mon Sep 17 00:00:00 2001 From: Yan Pujante Date: Mon, 16 Feb 2026 08:05:01 -0800 Subject: [PATCH 082/112] Added Emscripten external platform (comment) --- include/GLFW/glfw3.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 58989cc7a..5d9cff2e3 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1344,6 +1344,10 @@ extern "C" { #define GLFW_PLATFORM_NULL 0x00060005 /*! @} */ +/* Reserved platform define for external Emscripten ports: 0x00060006 + * See https://github.com/pongasoft/emscripten-glfw + */ + #define GLFW_DONT_CARE -1 From 29cd880ab5d5e3f8ebf31da1204037c81dab2489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Feb 2026 15:07:18 +0100 Subject: [PATCH 083/112] macOS: Clarify separation between Cocoa and macOS The timer code uses no part of Cocoa and is in turn used by other backends than Cocoa on macOS. The macOS timer code is now labeled macOS. Cocoa-specific files are now consistently labeled Cocoa, not macOS. --- src/CMakeLists.txt | 2 +- src/cocoa_init.m | 2 +- src/cocoa_monitor.m | 2 +- src/cocoa_platform.h | 2 +- src/cocoa_window.m | 2 +- src/{cocoa_time.c => macos_time.c} | 8 ++++---- src/{cocoa_time.h => macos_time.h} | 8 ++++---- src/platform.h | 10 +++++----- 8 files changed, 18 insertions(+), 18 deletions(-) rename src/{cocoa_time.c => macos_time.c} (90%) rename src/{cocoa_time.h => macos_time.h} (89%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2cbe8a733..942e27992 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,7 @@ add_library(glfw ${GLFW_LIBRARY_TYPE} # The time, thread and module code is shared between all backends on a given OS, # including the null backend, which still needs those bits to be functional if (APPLE) - target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h + target_sources(glfw PRIVATE macos_time.h macos_time.c posix_thread.h posix_module.c posix_thread.c) elseif (WIN32) target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 531d8b452..4b2094ca6 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.5 macOS - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 6495e1f3b..620a8cfb7 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.5 macOS - www.glfw.org +// GLFW 3.5 Cocoa - 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 4d1d66ae0..a25d1b2b7 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.5 macOS - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 2bff22a6b..1769f79b4 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.5 macOS - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_time.c b/src/macos_time.c similarity index 90% rename from src/cocoa_time.c rename to src/macos_time.c index a153edb38..c66ea3c9b 100644 --- a/src/cocoa_time.c +++ b/src/macos_time.c @@ -26,7 +26,7 @@ #include "internal.h" -#if defined(GLFW_BUILD_COCOA_TIMER) +#if defined(GLFW_BUILD_MACOS_TIMER) #include @@ -40,7 +40,7 @@ void _glfwPlatformInitTimer(void) mach_timebase_info_data_t info; mach_timebase_info(&info); - _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer; + _glfw.timer.macos.frequency = (info.denom * 1e9) / info.numer; } uint64_t _glfwPlatformGetTimerValue(void) @@ -50,8 +50,8 @@ uint64_t _glfwPlatformGetTimerValue(void) uint64_t _glfwPlatformGetTimerFrequency(void) { - return _glfw.timer.ns.frequency; + return _glfw.timer.macos.frequency; } -#endif // GLFW_BUILD_COCOA_TIMER +#endif // GLFW_BUILD_MACOS_TIMER diff --git a/src/cocoa_time.h b/src/macos_time.h similarity index 89% rename from src/cocoa_time.h rename to src/macos_time.h index 8463cbb65..77bf119ae 100644 --- a/src/cocoa_time.h +++ b/src/macos_time.h @@ -24,12 +24,12 @@ // //======================================================================== -#define GLFW_COCOA_LIBRARY_TIMER_STATE _GLFWtimerNS ns; +#define GLFW_MACOS_LIBRARY_TIMER_STATE _GLFWtimerMacOS macos; -// Cocoa-specific global timer data +// macOS-specific global timer data // -typedef struct _GLFWtimerNS +typedef struct _GLFWtimerMacOS { uint64_t frequency; -} _GLFWtimerNS; +} _GLFWtimerMacOS; diff --git a/src/platform.h b/src/platform.h index 7ce4e015a..e196e387c 100644 --- a/src/platform.h +++ b/src/platform.h @@ -28,7 +28,7 @@ #if defined(GLFW_BUILD_WIN32_TIMER) || \ defined(GLFW_BUILD_WIN32_MODULE) || \ defined(GLFW_BUILD_WIN32_THREAD) || \ - defined(GLFW_BUILD_COCOA_TIMER) || \ + defined(GLFW_BUILD_MACOS_TIMER) || \ defined(GLFW_BUILD_POSIX_TIMER) || \ defined(GLFW_BUILD_POSIX_MODULE) || \ defined(GLFW_BUILD_POSIX_THREAD) || \ @@ -184,7 +184,7 @@ #if defined(_WIN32) #define GLFW_BUILD_WIN32_TIMER #elif defined(__APPLE__) - #define GLFW_BUILD_COCOA_TIMER + #define GLFW_BUILD_MACOS_TIMER #else #define GLFW_BUILD_POSIX_TIMER #endif @@ -192,9 +192,9 @@ #if defined(GLFW_BUILD_WIN32_TIMER) #include "win32_time.h" #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE -#elif defined(GLFW_BUILD_COCOA_TIMER) - #include "cocoa_time.h" - #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE +#elif defined(GLFW_BUILD_MACOS_TIMER) + #include "macos_time.h" + #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_MACOS_LIBRARY_TIMER_STATE #elif defined(GLFW_BUILD_POSIX_TIMER) #include "posix_time.h" #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE From c5c0b69149382c424d9eb1753635eb407fdb5935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Feb 2026 15:20:50 +0100 Subject: [PATCH 084/112] Fix pkgconfig dependency lists treated as strings All other parts of the file correctly treated these variables as lists. --- src/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 942e27992..cf71feca5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -148,8 +148,10 @@ if (GLFW_BUILD_COCOA) "-framework CoreFoundation" "-framework QuartzCore") - set(glfw_PKG_DEPS "") - set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation -framework QuartzCore") + list(APPEND glfw_PKG_LIBS "-framework Cocoa" + "-framework IOKit" + "-framework CoreFoundation" + "-framework QuartzCore") endif() if (GLFW_BUILD_WAYLAND) From bae8aa6e7df66d79e6aa5bad2a452c5b4307a9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Feb 2026 15:36:15 +0100 Subject: [PATCH 085/112] macOS: Fix Vulkan loader loading for Null platform --- src/CMakeLists.txt | 7 +++++-- src/cocoa_init.m | 35 ----------------------------------- src/cocoa_platform.h | 2 -- src/vulkan.c | 39 ++++++++++++++++++++++++++++++++++++--- 4 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf71feca5..ab096c95b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -145,12 +145,10 @@ endif() if (GLFW_BUILD_COCOA) target_link_libraries(glfw PRIVATE "-framework Cocoa" "-framework IOKit" - "-framework CoreFoundation" "-framework QuartzCore") list(APPEND glfw_PKG_LIBS "-framework Cocoa" "-framework IOKit" - "-framework CoreFoundation" "-framework QuartzCore") endif() @@ -236,6 +234,11 @@ if (UNIX AND NOT APPLE) endif() endif() +if (APPLE) + target_link_libraries(glfw PRIVATE "-framework CoreFoundation") + list(APPEND glfw_PKG_LIBS "-framework CoreFoundation") +endif() + if (WIN32) if (GLFW_USE_HYBRID_HPG) target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 4b2094ca6..95d6289e3 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -450,41 +450,6 @@ static GLFWbool initializeTIS(void) @end // GLFWApplicationDelegate - -////////////////////////////////////////////////////////////////////////// -////// GLFW internal API ////// -////////////////////////////////////////////////////////////////////////// - -void* _glfwLoadLocalVulkanLoaderCocoa(void) -{ - CFBundleRef bundle = CFBundleGetMainBundle(); - if (!bundle) - return NULL; - - CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle); - if (!frameworksUrl) - return NULL; - - CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent( - kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false); - if (!loaderUrl) - { - CFRelease(frameworksUrl); - return NULL; - } - - char path[PATH_MAX]; - void* handle = NULL; - - if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8*) path, sizeof(path) - 1)) - handle = _glfwPlatformLoadModule(path); - - CFRelease(loaderUrl); - CFRelease(frameworksUrl); - return handle; -} - - ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index a25d1b2b7..175372d60 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -291,8 +291,6 @@ void _glfwRestoreVideoModeCocoa(_GLFWmonitor* monitor); float _glfwTransformYCocoa(float y); -void* _glfwLoadLocalVulkanLoaderCocoa(void); - GLFWbool _glfwInitNSGL(void); void _glfwTerminateNSGL(void); GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, diff --git a/src/vulkan.c b/src/vulkan.c index b52a57fce..03642a31b 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -34,6 +34,40 @@ #define _GLFW_FIND_LOADER 1 #define _GLFW_REQUIRE_LOADER 2 +#if defined(__APPLE__) + +#include + +static void* loadLocalVulkanLoaderMacOS(void) +{ + CFBundleRef bundle = CFBundleGetMainBundle(); + if (!bundle) + return NULL; + + CFURLRef frameworksUrl = CFBundleCopyPrivateFrameworksURL(bundle); + if (!frameworksUrl) + return NULL; + + CFURLRef loaderUrl = CFURLCreateCopyAppendingPathComponent( + kCFAllocatorDefault, frameworksUrl, CFSTR("libvulkan.1.dylib"), false); + if (!loaderUrl) + { + CFRelease(frameworksUrl); + return NULL; + } + + char path[PATH_MAX]; + void* handle = NULL; + + if (CFURLGetFileSystemRepresentation(loaderUrl, true, (UInt8*) path, sizeof(path) - 1)) + handle = _glfwPlatformLoadModule(path); + + CFRelease(loaderUrl); + CFRelease(frameworksUrl); + return handle; +} + +#endif // __APPLE__ ////////////////////////////////////////////////////////////////////////// ////// GLFW internal API ////// @@ -57,11 +91,10 @@ GLFWbool _glfwInitVulkan(int mode) _glfw.vk.handle = _glfwPlatformLoadModule(_GLFW_VULKAN_LIBRARY); #elif defined(_WIN32) _glfw.vk.handle = _glfwPlatformLoadModule("vulkan-1.dll"); -#elif defined(_GLFW_COCOA) +#elif defined(__APPLE__) _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.1.dylib"); if (!_glfw.vk.handle) - _glfw.vk.handle = _glfwLoadLocalVulkanLoaderCocoa(); -#elif defined(__APPLE__) + _glfw.vk.handle = loadLocalVulkanLoaderMacOS(); #elif defined(__OpenBSD__) || defined(__NetBSD__) _glfw.vk.handle = _glfwPlatformLoadModule("libvulkan.so"); #else From aa5047709d1dbc639db089e60a4c455ad1c7b69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Feb 2026 17:29:54 +0100 Subject: [PATCH 086/112] POSIX: Include helper header via platform glue --- src/platform.h | 1 + src/wl_platform.h | 2 -- src/x11_platform.h | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/platform.h b/src/platform.h index e196e387c..398f463f5 100644 --- a/src/platform.h +++ b/src/platform.h @@ -207,6 +207,7 @@ #endif #if defined(_GLFW_WAYLAND) || defined(_GLFW_X11) + #include "posix_poll.h" #define GLFW_BUILD_POSIX_POLL #endif diff --git a/src/wl_platform.h b/src/wl_platform.h index c9d1c2512..d03ba1da2 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -42,8 +42,6 @@ typedef struct VkWaylandSurfaceCreateInfoKHR typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*); -#include "posix_poll.h" - typedef int (* PFN_wl_display_flush)(struct wl_display* display); typedef void (* PFN_wl_display_cancel_read)(struct wl_display* display); typedef int (* PFN_wl_display_dispatch_pending)(struct wl_display* display); diff --git a/src/x11_platform.h b/src/x11_platform.h index 1bfeaab49..36dfcce1a 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -453,7 +453,6 @@ typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSur typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t); #include "xkb_unicode.h" -#include "posix_poll.h" #define GLFW_X11_WINDOW_STATE _GLFWwindowX11 x11; #define GLFW_X11_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11; From 1839271de46c572e556c8d8a974299edd22ffaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 16 Feb 2026 17:36:57 +0100 Subject: [PATCH 087/112] Wayland: Remove last traces of legacy Unicode path The legacy keysym-to-Unicode path is only used on X11 since 21fea01161e0d6b70c0c5c1f52dc8e7a7df14a50, but the file was still included in Wayland-only builds. --- src/CMakeLists.txt | 2 +- src/x11_platform.h | 5 +++-- src/x11_window.c | 4 ++-- src/xkb_unicode.c | 6 +++--- src/xkb_unicode.h | 30 ------------------------------ 5 files changed, 9 insertions(+), 38 deletions(-) delete mode 100644 src/xkb_unicode.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ab096c95b..24f099fec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,7 +46,7 @@ endif() if (GLFW_BUILD_X11) target_compile_definitions(glfw PRIVATE _GLFW_X11) - target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h x11_init.c + target_sources(glfw PRIVATE x11_platform.h x11_init.c x11_monitor.c x11_window.c xkb_unicode.c glx_context.c) endif() diff --git a/src/x11_platform.h b/src/x11_platform.h index 36dfcce1a..f3a037f1e 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -452,8 +452,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(V typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t); -#include "xkb_unicode.h" - #define GLFW_X11_WINDOW_STATE _GLFWwindowX11 x11; #define GLFW_X11_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11; #define GLFW_X11_MONITOR_STATE _GLFWmonitorX11 x11; @@ -462,6 +460,7 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk #define GLFW_GLX_CONTEXT_STATE _GLFWcontextGLX glx; #define GLFW_GLX_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx; +#define GLFW_INVALID_CODEPOINT 0xffffffffu // GLX-specific per-context data // @@ -984,6 +983,8 @@ unsigned long _glfwGetWindowPropertyX11(Window window, unsigned char** value); GLFWbool _glfwIsVisualTransparentX11(Visual* visual); +uint32_t _glfwKeySym2UnicodeX11(unsigned int keysym); + void _glfwGrabErrorHandlerX11(void); void _glfwReleaseErrorHandlerX11(void); void _glfwInputErrorX11(int error, const char* message); diff --git a/src/x11_window.c b/src/x11_window.c index 47b9ad1e2..f46a7e6ce 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1308,7 +1308,7 @@ static void processEvent(XEvent *event) _glfwInputKey(window, key, keycode, GLFW_PRESS, mods); - const uint32_t codepoint = _glfwKeySym2Unicode(keysym); + const uint32_t codepoint = _glfwKeySym2UnicodeX11(keysym); if (codepoint != GLFW_INVALID_CODEPOINT) _glfwInputChar(window, codepoint, mods, plain); } @@ -2944,7 +2944,7 @@ const char* _glfwGetScancodeNameX11(int scancode) if (keysym == NoSymbol) return NULL; - const uint32_t codepoint = _glfwKeySym2Unicode(keysym); + const uint32_t codepoint = _glfwKeySym2UnicodeX11(keysym); if (codepoint == GLFW_INVALID_CODEPOINT) return NULL; diff --git a/src/xkb_unicode.c b/src/xkb_unicode.c index 68767cc36..7a4ee10a7 100644 --- a/src/xkb_unicode.c +++ b/src/xkb_unicode.c @@ -27,7 +27,7 @@ #include "internal.h" -#if defined(_GLFW_X11) || defined(_GLFW_WAYLAND) +#if defined(_GLFW_X11) /* * Marcus: This code was originally written by Markus G. Kuhn. @@ -906,7 +906,7 @@ static const struct codepair { // Convert XKB KeySym to Unicode // -uint32_t _glfwKeySym2Unicode(unsigned int keysym) +uint32_t _glfwKeySym2UnicodeX11(unsigned int keysym) { int min = 0; int max = sizeof(keysymtab) / sizeof(struct codepair) - 1; @@ -939,5 +939,5 @@ uint32_t _glfwKeySym2Unicode(unsigned int keysym) return GLFW_INVALID_CODEPOINT; } -#endif // _GLFW_WAYLAND or _GLFW_X11 +#endif // _GLFW_X11 diff --git a/src/xkb_unicode.h b/src/xkb_unicode.h deleted file mode 100644 index d52748ac2..000000000 --- a/src/xkb_unicode.h +++ /dev/null @@ -1,30 +0,0 @@ -//======================================================================== -// GLFW 3.5 Linux - www.glfw.org -//------------------------------------------------------------------------ -// Copyright (c) 2014 Jonas Ådahl -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would -// be appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not -// be misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//======================================================================== - -#define GLFW_INVALID_CODEPOINT 0xffffffffu - -uint32_t _glfwKeySym2Unicode(unsigned int keysym); - From f472380d7e49ee17ca366af8b8d9eb39fd413c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Feb 2026 14:14:36 +0100 Subject: [PATCH 088/112] Use C99 isfinite instead of various ad-hoc tests --- src/input.c | 18 +++++++----------- src/monitor.c | 5 +++-- src/window.c | 15 +++++++-------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/input.c b/src/input.c index c619eefce..b68ddef4d 100644 --- a/src/input.c +++ b/src/input.c @@ -333,10 +333,8 @@ void _glfwInputChar(_GLFWwindow* window, uint32_t codepoint, int mods, GLFWbool void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset) { assert(window != NULL); - assert(xoffset > -FLT_MAX); - assert(xoffset < FLT_MAX); - assert(yoffset > -FLT_MAX); - assert(yoffset < FLT_MAX); + assert(isfinite(xoffset)); + assert(isfinite(yoffset)); if (window->callbacks.scroll) window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset); @@ -375,10 +373,8 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods) void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos) { assert(window != NULL); - assert(xpos > -FLT_MAX); - assert(xpos < FLT_MAX); - assert(ypos > -FLT_MAX); - assert(ypos < FLT_MAX); + assert(isfinite(xpos)); + assert(isfinite(ypos)); if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos) return; @@ -436,6 +432,7 @@ void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value) assert(js != NULL); assert(axis >= 0); assert(axis < js->axisCount); + assert(isfinite(value)); js->axes[axis] = value; } @@ -818,8 +815,7 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos) _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX || - ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX) + if (!isfinite(xpos) || !isfinite(ypos)) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid cursor position %f %f", @@ -1499,7 +1495,7 @@ GLFWAPI void glfwSetTime(double time) { _GLFW_REQUIRE_INIT(); - if (time != time || time < 0.0 || time > 18446744073.0) + if (!isfinite(time) || time < 0.0 || time > 18446744073.0) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", time); return; diff --git a/src/monitor.c b/src/monitor.c index cc95efb64..7cdf2df1f 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -467,14 +467,15 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma) unsigned short* values; GLFWgammaramp ramp; const GLFWgammaramp* original; + assert(gamma > 0.f); - assert(gamma <= FLT_MAX); + assert(isfinite(gamma)); _GLFW_REQUIRE_INIT(); assert(handle != NULL); - if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX) + if (!isfinite(gamma) || gamma <= 0.f) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma); return; diff --git a/src/window.c b/src/window.c index 3a3b66dfe..36d30baf7 100644 --- a/src/window.c +++ b/src/window.c @@ -32,7 +32,7 @@ #include #include #include - +#include ////////////////////////////////////////////////////////////////////////// ////// GLFW event API ////// @@ -135,9 +135,9 @@ void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscal { assert(window != NULL); assert(xscale > 0.f); - assert(xscale < FLT_MAX); + assert(isfinite(xscale)); assert(yscale > 0.f); - assert(yscale < FLT_MAX); + assert(isfinite(yscale)); if (window->callbacks.scale) window->callbacks.scale((GLFWwindow*) window, xscale, yscale); @@ -776,7 +776,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle) GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity) { - assert(opacity == opacity); + assert(isfinite(opacity)); assert(opacity >= 0.f); assert(opacity <= 1.f); @@ -785,7 +785,7 @@ GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity) _GLFWwindow* window = (_GLFWwindow*) handle; assert(window != NULL); - if (opacity != opacity || opacity < 0.f || opacity > 1.f) + if (!isfinite(opacity) || opacity < 0.f || opacity > 1.f) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid window opacity %f", opacity); return; @@ -1178,11 +1178,10 @@ GLFWAPI void glfwWaitEvents(void) GLFWAPI void glfwWaitEventsTimeout(double timeout) { _GLFW_REQUIRE_INIT(); - assert(timeout == timeout); + assert(isfinite(timeout)); assert(timeout >= 0.0); - assert(timeout <= DBL_MAX); - if (timeout != timeout || timeout < 0.0 || timeout > DBL_MAX) + if (!isfinite(timeout) || timeout < 0.0) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", timeout); return; From 0d15b54c7ac1eac52946aacafd5fe103a41fe6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Feb 2026 16:57:28 +0100 Subject: [PATCH 089/112] Use C99 booleans in config structs --- src/context.c | 2 +- src/egl_context.c | 2 +- src/glx_context.c | 4 +-- src/init.c | 8 +++--- src/internal.h | 52 +++++++++++++++++++-------------------- src/wgl_context.c | 20 +++++---------- src/window.c | 62 +++++++++++++++++++++++------------------------ 7 files changed, 70 insertions(+), 80 deletions(-) diff --git a/src/context.c b/src/context.c index f4fa63ad7..d92ed4020 100644 --- a/src/context.c +++ b/src/context.c @@ -195,7 +195,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, { current = alternatives + i; - if (desired->stereo > 0 && current->stereo == 0) + if (desired->stereo && !current->stereo) { // Stereo is a hard constraint continue; diff --git a/src/egl_context.c b/src/egl_context.c index 156adb40f..7586d5a3d 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -650,7 +650,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (ctxconfig->noerror) { if (_glfw.egl.KHR_create_context_no_error) - SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE); + SET_ATTRIB(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, true); } if (mask) diff --git a/src/glx_context.c b/src/glx_context.c index f08cdd5b8..3d98d2a03 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -119,9 +119,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE); u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS); - - if (getGLXFBConfigAttrib(n, GLX_STEREO)) - u->stereo = GLFW_TRUE; + u->stereo = getGLXFBConfigAttrib(n, GLX_STEREO); if (_glfw.glx.ARB_multisample) u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES); diff --git a/src/init.c b/src/init.c index dbd5a900c..7cd872c7f 100644 --- a/src/init.c +++ b/src/init.c @@ -49,18 +49,18 @@ static GLFWerrorfun _glfwErrorCallback; static GLFWallocator _glfwInitAllocator; static _GLFWinitconfig _glfwInitHints = { - .hatButtons = GLFW_TRUE, + .hatButtons = true, .angleType = GLFW_ANGLE_PLATFORM_TYPE_NONE, .platformID = GLFW_ANY_PLATFORM, .vulkanLoader = NULL, .ns = { - .menubar = GLFW_TRUE, - .chdir = GLFW_TRUE + .menubar = true, + .chdir = true }, .x11 = { - .xcbVulkanSurface = GLFW_TRUE, + .xcbVulkanSurface = true, }, .wl = { diff --git a/src/internal.h b/src/internal.h index de703740f..15049a3ec 100644 --- a/src/internal.h +++ b/src/internal.h @@ -374,16 +374,16 @@ struct _GLFWerror // struct _GLFWinitconfig { - GLFWbool hatButtons; + bool hatButtons; int angleType; int platformID; PFN_vkGetInstanceProcAddr vulkanLoader; struct { - GLFWbool menubar; - GLFWbool chdir; + bool menubar; + bool chdir; } ns; struct { - GLFWbool xcbVulkanSurface; + bool xcbVulkanSurface; } x11; struct { int libdecorMode; @@ -402,18 +402,18 @@ struct _GLFWwndconfig int ypos; int width; int height; - GLFWbool resizable; - GLFWbool visible; - GLFWbool decorated; - GLFWbool focused; - GLFWbool autoIconify; - GLFWbool floating; - GLFWbool maximized; - GLFWbool centerCursor; - GLFWbool focusOnShow; - GLFWbool mousePassthrough; - GLFWbool scaleToMonitor; - GLFWbool scaleFramebuffer; + bool resizable; + bool visible; + bool decorated; + bool focused; + bool autoIconify; + bool floating; + bool maximized; + bool centerCursor; + bool focusOnShow; + bool mousePassthrough; + bool scaleToMonitor; + bool scaleFramebuffer; struct { char frameName[256]; } ns; @@ -422,8 +422,8 @@ struct _GLFWwndconfig char instanceName[256]; } x11; struct { - GLFWbool keymenu; - GLFWbool showDefault; + bool keymenu; + bool showDefault; } win32; struct { char appId[256]; @@ -442,15 +442,15 @@ struct _GLFWctxconfig int source; int major; int minor; - GLFWbool forward; - GLFWbool debug; - GLFWbool noerror; + bool forward; + bool debug; + bool noerror; int profile; int robustness; int release; _GLFWwindow* share; struct { - GLFWbool offline; + bool offline; } nsgl; }; @@ -475,11 +475,11 @@ struct _GLFWfbconfig int accumBlueBits; int accumAlphaBits; int auxBuffers; - GLFWbool stereo; + bool stereo; int samples; - GLFWbool sRGB; - GLFWbool doublebuffer; - GLFWbool transparent; + bool sRGB; + bool doublebuffer; + bool transparent; uintptr_t handle; }; diff --git a/src/wgl_context.c b/src/wgl_context.c index 1fb7d322e..dac695e35 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -186,28 +186,22 @@ static int choosePixelFormatWGL(_GLFWwindow* window, u->accumAlphaBits = FIND_ATTRIB_VALUE(WGL_ACCUM_ALPHA_BITS_ARB); u->auxBuffers = FIND_ATTRIB_VALUE(WGL_AUX_BUFFERS_ARB); - - if (FIND_ATTRIB_VALUE(WGL_STEREO_ARB)) - u->stereo = GLFW_TRUE; + u->stereo = FIND_ATTRIB_VALUE(WGL_STEREO_ARB); if (_glfw.wgl.ARB_multisample) u->samples = FIND_ATTRIB_VALUE(WGL_SAMPLES_ARB); if (ctxconfig->client == GLFW_OPENGL_API) { - if (_glfw.wgl.ARB_framebuffer_sRGB || - _glfw.wgl.EXT_framebuffer_sRGB) - { - if (FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB)) - u->sRGB = GLFW_TRUE; - } + if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB) + u->sRGB = FIND_ATTRIB_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); } else { if (_glfw.wgl.EXT_colorspace) { if (FIND_ATTRIB_VALUE(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT) - u->sRGB = GLFW_TRUE; + u->sRGB = true; } } } @@ -261,9 +255,7 @@ static int choosePixelFormatWGL(_GLFWwindow* window, u->accumAlphaBits = pfd.cAccumAlphaBits; u->auxBuffers = pfd.cAuxBuffers; - - if (pfd.dwFlags & PFD_STEREO) - u->stereo = GLFW_TRUE; + u->stereo = (pfd.dwFlags & PFD_STEREO); } u->handle = pixelFormat; @@ -664,7 +656,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, if (ctxconfig->noerror) { if (_glfw.wgl.ARB_create_context_no_error) - SET_ATTRIB(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE); + SET_ATTRIB(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, true); } // NOTE: Only request an explicitly versioned context when necessary, as diff --git a/src/window.c b/src/window.c index 36d30baf7..5f92e97f9 100644 --- a/src/window.c +++ b/src/window.c @@ -265,16 +265,16 @@ void glfwDefaultWindowHints(void) // The default is a focused, visible, resizable window with decorations memset(&_glfw.hints.window, 0, sizeof(_glfw.hints.window)); - _glfw.hints.window.resizable = GLFW_TRUE; - _glfw.hints.window.visible = GLFW_TRUE; - _glfw.hints.window.decorated = GLFW_TRUE; - _glfw.hints.window.focused = GLFW_TRUE; - _glfw.hints.window.autoIconify = GLFW_TRUE; - _glfw.hints.window.centerCursor = GLFW_TRUE; - _glfw.hints.window.focusOnShow = GLFW_TRUE; + _glfw.hints.window.resizable = true; + _glfw.hints.window.visible = true; + _glfw.hints.window.decorated = true; + _glfw.hints.window.focused = true; + _glfw.hints.window.autoIconify = true; + _glfw.hints.window.centerCursor = true; + _glfw.hints.window.focusOnShow = true; _glfw.hints.window.xpos = GLFW_ANY_POSITION; _glfw.hints.window.ypos = GLFW_ANY_POSITION; - _glfw.hints.window.scaleFramebuffer = GLFW_TRUE; + _glfw.hints.window.scaleFramebuffer = true; // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil, // double buffered @@ -285,7 +285,7 @@ void glfwDefaultWindowHints(void) _glfw.hints.framebuffer.alphaBits = 8; _glfw.hints.framebuffer.depthBits = 24; _glfw.hints.framebuffer.stencilBits = 8; - _glfw.hints.framebuffer.doublebuffer = GLFW_TRUE; + _glfw.hints.framebuffer.doublebuffer = true; // The default is to select the highest available refresh rate _glfw.hints.refreshRate = GLFW_DONT_CARE; @@ -331,40 +331,40 @@ GLFWAPI void glfwWindowHint(int hint, int value) _glfw.hints.framebuffer.auxBuffers = value; return; case GLFW_STEREO: - _glfw.hints.framebuffer.stereo = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.framebuffer.stereo = value; return; case GLFW_DOUBLEBUFFER: - _glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.framebuffer.doublebuffer = value; return; case GLFW_TRANSPARENT_FRAMEBUFFER: - _glfw.hints.framebuffer.transparent = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.framebuffer.transparent = value; return; case GLFW_SAMPLES: _glfw.hints.framebuffer.samples = value; return; case GLFW_SRGB_CAPABLE: - _glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.framebuffer.sRGB = value; return; case GLFW_RESIZABLE: - _glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.resizable = value; return; case GLFW_DECORATED: - _glfw.hints.window.decorated = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.decorated = value; return; case GLFW_FOCUSED: - _glfw.hints.window.focused = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.focused = value; return; case GLFW_AUTO_ICONIFY: - _glfw.hints.window.autoIconify = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.autoIconify = value; return; case GLFW_FLOATING: - _glfw.hints.window.floating = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.floating = value; return; case GLFW_MAXIMIZED: - _glfw.hints.window.maximized = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.maximized = value; return; case GLFW_VISIBLE: - _glfw.hints.window.visible = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.visible = value; return; case GLFW_POSITION_X: _glfw.hints.window.xpos = value; @@ -373,29 +373,29 @@ GLFWAPI void glfwWindowHint(int hint, int value) _glfw.hints.window.ypos = value; return; case GLFW_WIN32_KEYBOARD_MENU: - _glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.win32.keymenu = value; return; case GLFW_WIN32_SHOWDEFAULT: - _glfw.hints.window.win32.showDefault = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.win32.showDefault = value; return; case GLFW_COCOA_GRAPHICS_SWITCHING: - _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.context.nsgl.offline = value; return; case GLFW_SCALE_TO_MONITOR: - _glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.scaleToMonitor = value; return; case GLFW_SCALE_FRAMEBUFFER: case GLFW_COCOA_RETINA_FRAMEBUFFER: - _glfw.hints.window.scaleFramebuffer = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.scaleFramebuffer = value; return; case GLFW_CENTER_CURSOR: - _glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.centerCursor = value; return; case GLFW_FOCUS_ON_SHOW: - _glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.focusOnShow = value; return; case GLFW_MOUSE_PASSTHROUGH: - _glfw.hints.window.mousePassthrough = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.window.mousePassthrough = value; return; case GLFW_CLIENT_API: _glfw.hints.context.client = value; @@ -413,13 +413,13 @@ GLFWAPI void glfwWindowHint(int hint, int value) _glfw.hints.context.robustness = value; return; case GLFW_OPENGL_FORWARD_COMPAT: - _glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.context.forward = value; return; case GLFW_CONTEXT_DEBUG: - _glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.context.debug = value; return; case GLFW_CONTEXT_NO_ERROR: - _glfw.hints.context.noerror = value ? GLFW_TRUE : GLFW_FALSE; + _glfw.hints.context.noerror = value; return; case GLFW_OPENGL_PROFILE: _glfw.hints.context.profile = value; From 05f57c0beecc03326e4f1e96ec2baa983706c7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 5 Feb 2026 20:05:19 +0100 Subject: [PATCH 090/112] Wayland: Improve support for discrete scrolling This adds support for high-resolution scroll input scaled to match legacy discrete scroll input. It is available on compositors that support wl_seat version 8 or later. High-resolution "discrete" values now replace non-scaled scroll values when available. --- README.md | 1 + src/wl_init.c | 2 +- src/wl_platform.h | 2 ++ src/wl_window.c | 33 ++++++++++++++++++++++++++------- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ab346ae65..40443e4dc 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: The `libwayland-client` library was not unloaded at termination - [Wayland] Bugfix: Scroll events were sent twice on some versions of GNOME (#2494) - [Wayland] Bugfix: Two-dimensional scroll input was emitted as separate axes + - [Wayland] Bugfix: Mouse wheel scroll distance was incorrect on some compositors - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/wl_init.c b/src/wl_init.c index 1e5276490..50421eb26 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -135,7 +135,7 @@ static void registryHandleGlobal(void* userData, { _glfw.wl.seat = wl_registry_bind(registry, name, &wl_seat_interface, - _glfw_min(5, version)); + _glfw_min(8, version)); _glfwAddSeatListenerWayland(_glfw.wl.seat); } } diff --git a/src/wl_platform.h b/src/wl_platform.h index d03ba1da2..9bd3b0ef6 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -478,6 +478,8 @@ typedef struct _GLFWlibraryWayland double pointerY; double scrollX; double scrollY; + double discreteX; + double discreteY; int button; int action; } pending; diff --git a/src/wl_window.c b/src/wl_window.c index dd097cf9f..b9dbaa3b2 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -55,10 +55,11 @@ #define GLFW_BORDER_SIZE 4 #define GLFW_CAPTION_HEIGHT 24 -#define GLFW_PENDING_SURFACE 1 -#define GLFW_PENDING_BUTTON 2 -#define GLFW_PENDING_MOTION 4 -#define GLFW_PENDING_SCROLL 8 +#define GLFW_PENDING_SURFACE 1 +#define GLFW_PENDING_BUTTON 2 +#define GLFW_PENDING_MOTION 4 +#define GLFW_PENDING_SCROLL 8 +#define GLFW_PENDING_DISCRETE 16 static int createTmpfileCloexec(char* tmpname) { @@ -1740,7 +1741,9 @@ static void pointerHandleFrame(void* userData, struct wl_pointer* pointer) if (_glfw.wl.pending.events & GLFW_PENDING_BUTTON) processPointerButton(_glfw.wl.pending.button, _glfw.wl.pending.action); - if (_glfw.wl.pending.events & GLFW_PENDING_SCROLL) + if (_glfw.wl.pending.events & GLFW_PENDING_DISCRETE) + processPointerScroll(_glfw.wl.pending.discreteX, _glfw.wl.pending.discreteY); + else if (_glfw.wl.pending.events & GLFW_PENDING_SCROLL) processPointerScroll(_glfw.wl.pending.scrollX, _glfw.wl.pending.scrollY); memset(&_glfw.wl.pending, 0, sizeof(_glfw.wl.pending)); @@ -1766,6 +1769,21 @@ static void pointerHandleAxisDiscrete(void* userData, { } +static void pointerHandleAxisValue120(void* data, + struct wl_pointer* pointer, + uint32_t axis, + int32_t value120) +{ + if (!_glfw.wl.pointerSurface) + return; + + _glfw.wl.pending.events |= GLFW_PENDING_DISCRETE; + if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) + _glfw.wl.pending.discreteX = -(value120 / 120.0); + else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) + _glfw.wl.pending.discreteY = -(value120 / 120.0); +} + static const struct wl_pointer_listener pointerListener = { pointerHandleEnter, @@ -1776,7 +1794,8 @@ static const struct wl_pointer_listener pointerListener = pointerHandleFrame, pointerHandleAxisSource, pointerHandleAxisStop, - pointerHandleAxisDiscrete + pointerHandleAxisDiscrete, + pointerHandleAxisValue120 }; static void keyboardHandleKeymap(void* userData, @@ -1799,7 +1818,7 @@ static void keyboardHandleKeymap(void* userData, return; } - mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); + mapStr = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); if (mapStr == MAP_FAILED) { close(fd); From 54b18d5547e641d7ccd8c47d9221efcf590a598c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 18 Feb 2026 19:12:45 +0100 Subject: [PATCH 091/112] Fix cleanup on success in threaded rendering test --- tests/threads.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/threads.c b/tests/threads.c index a2caea56f..988d0eba1 100644 --- a/tests/threads.c +++ b/tests/threads.c @@ -146,6 +146,10 @@ int main(void) for (i = 0; i < count; i++) thrd_join(threads[i].id, &result); + for (i = 0; i < count; i++) + glfwDestroyWindow(threads[i].window); + + glfwTerminate(); exit(EXIT_SUCCESS); } From fdd14e65b1c29e4e6df875fb5669ec00d6793531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 17 Feb 2026 19:44:39 +0100 Subject: [PATCH 092/112] Wayland: Fix EGL buffer swap blocking indefinitely When the swap interval was nonzero, EGL on Wayland would wait indefinitely for a frame callback on a suspended window, causing applications that call eglSwapBuffers to halt. This re-implements the wait for a surface frame so that we can add a reasonable timeout, while setting the EGL swap interval to zero. That allows applications to make progress despite the window being suspended. Some insights for how to structure this workaround were gleaned from dri2_wl_swap_buffers_with_damage in Mesa. This initial implementation still has a race between glfwHideWindow and glfwSwapBuffers when rendering on a separate thread. This could lead to a window becoming visible again after being hidden on the main thread. Related to #1350 Fixes #2582 Fixes #2640 Fixes #2719 Fixes #2723 Fixes #2800 Fixes #2827 --- CONTRIBUTORS.md | 3 ++ README.md | 2 ++ include/GLFW/glfw3.h | 4 +++ src/context.c | 7 ++++- src/egl_context.c | 25 +++++++++++++++ src/internal.h | 2 ++ src/wl_init.c | 23 +++++++++++++- src/wl_platform.h | 27 ++++++++++++++++ src/wl_window.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 166 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7a544eb61..9bfcdf86b 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -10,6 +10,7 @@ video tutorials. - Matt Arsenault - Takuro Ashie - ashishgamedev + - avagordon01 - David Avedissian - Luca Bacci - Keith Bauer @@ -75,6 +76,7 @@ video tutorials. - Nikita Fediuchin - Felipe Ferreira - Michael Fogleman + - Folling - forworldm - Jason Francis - Gerald Franz @@ -161,6 +163,7 @@ video tutorials. - Bryce Mehring - Jonathan Mercier - Marcel Metz + - Lucas Michaudel - Liam Middlebrook - mightgoyardstill - Mihail diff --git a/README.md b/README.md index 40443e4dc..0723e8352 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,8 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Scroll events were sent twice on some versions of GNOME (#2494) - [Wayland] Bugfix: Two-dimensional scroll input was emitted as separate axes - [Wayland] Bugfix: Mouse wheel scroll distance was incorrect on some compositors + - [Wayland] Bugfix: `glfwSwapBuffers` would halt with nonzero swap interval when window + was suspended (#1350,#2582,#2640,#2719,#2723,#2800,#2827) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 5d9cff2e3..16689a945 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -6174,6 +6174,10 @@ GLFWAPI GLFWwindow* glfwGetCurrentContext(void); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. * + * @remark __Wayland:__ When the swap interval is greater than zero and the + * window is not in view, this function may take a few extra milliseconds to + * return. + * * @remark __EGL:__ The context of the specified window must be current on the * calling thread. * diff --git a/src/context.c b/src/context.c index d92ed4020..a584cb12f 100644 --- a/src/context.c +++ b/src/context.c @@ -368,7 +368,12 @@ GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window, window->context.getProcAddress("glGetIntegerv"); window->context.GetString = (PFNGLGETSTRINGPROC) window->context.getProcAddress("glGetString"); - if (!window->context.GetIntegerv || !window->context.GetString) + window->context.Flush = (PFNGLFLUSHPROC) + window->context.getProcAddress("glFlush"); + + if (!window->context.GetIntegerv || + !window->context.GetString || + !window->context.Flush) { _glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken"); glfwMakeContextCurrent((GLFWwindow*) previous); diff --git a/src/egl_context.c b/src/egl_context.c index 7586d5a3d..4d436d398 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -254,6 +254,12 @@ static void makeContextCurrentEGL(_GLFWwindow* window) getEGLErrorString(eglGetError())); return; } + +#if defined(_GLFW_WAYLAND) + // NOTE: Disable EGL vsync so we can substitute our own that includes a timeout + if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND) + eglSwapInterval(_glfw.egl.display, 0); +#endif // _GLFW_WAYLAND } else { @@ -287,6 +293,15 @@ static void swapBuffersEGL(_GLFWwindow* window) // NOTE: Swapping buffers on a hidden window on Wayland makes it visible if (!window->wl.visible) return; + + // NOTE: We wait for a frame manually so we can add a timeout, + // as the EGL implementation will wait indefinitely + if (window->wl.egl.interval > 0) + { + window->context.Flush(); + if (!_glfwWaitForEGLFrameWayland(window)) + return; + } } #endif @@ -295,6 +310,16 @@ static void swapBuffersEGL(_GLFWwindow* window) static void swapIntervalEGL(int interval) { +#if defined(_GLFW_WAYLAND) + if (_glfw.platform.platformID == GLFW_PLATFORM_WAYLAND) + { + _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + assert(window != NULL); + window->wl.egl.interval = interval; + return; + } +#endif + eglSwapInterval(_glfw.egl.display, interval); } diff --git a/src/internal.h b/src/internal.h index 15049a3ec..56418c8df 100644 --- a/src/internal.h +++ b/src/internal.h @@ -109,6 +109,7 @@ typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield); typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum); typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*); typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); +typedef void (APIENTRY * PFNGLFLUSHPROC)(void); #define EGL_SUCCESS 0x3000 #define EGL_NOT_INITIALIZED 0x3001 @@ -498,6 +499,7 @@ struct _GLFWcontext PFNGLGETSTRINGIPROC GetStringi; PFNGLGETINTEGERVPROC GetIntegerv; PFNGLGETSTRINGPROC GetString; + PFNGLFLUSHPROC Flush; void (*makeCurrent)(_GLFWwindow*); void (*swapBuffers)(_GLFWwindow*); diff --git a/src/wl_init.c b/src/wl_init.c index 50421eb26..25ceba0d6 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -578,6 +578,14 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_get_fd"); _glfw.wl.client.display_prepare_read = (PFN_wl_display_prepare_read) _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_prepare_read"); + _glfw.wl.client.display_create_queue = (PFN_wl_display_create_queue) + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_create_queue"); + _glfw.wl.client.display_prepare_read_queue = (PFN_wl_display_prepare_read_queue) + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_prepare_read_queue"); + _glfw.wl.client.display_dispatch_queue_pending = (PFN_wl_display_dispatch_queue_pending) + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_display_dispatch_queue_pending"); + _glfw.wl.client.event_queue_destroy = (PFN_wl_event_queue_destroy) + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_event_queue_destroy"); _glfw.wl.client.proxy_marshal = (PFN_wl_proxy_marshal) _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal"); _glfw.wl.client.proxy_add_listener = (PFN_wl_proxy_add_listener) @@ -600,6 +608,12 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_get_version"); _glfw.wl.client.proxy_marshal_flags = (PFN_wl_proxy_marshal_flags) _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_marshal_flags"); + _glfw.wl.client.proxy_create_wrapper = (PFN_wl_proxy_create_wrapper) + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_create_wrapper"); + _glfw.wl.client.proxy_wrapper_destroy = (PFN_wl_proxy_wrapper_destroy) + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_wrapper_destroy"); + _glfw.wl.client.proxy_set_queue = (PFN_wl_proxy_set_queue) + _glfwPlatformGetModuleSymbol(_glfw.wl.client.handle, "wl_proxy_set_queue"); if (!_glfw.wl.client.display_flush || !_glfw.wl.client.display_cancel_read || @@ -609,6 +623,10 @@ int _glfwInitWayland(void) !_glfw.wl.client.display_roundtrip || !_glfw.wl.client.display_get_fd || !_glfw.wl.client.display_prepare_read || + !_glfw.wl.client.display_create_queue || + !_glfw.wl.client.display_prepare_read_queue || + !_glfw.wl.client.display_dispatch_queue_pending || + !_glfw.wl.client.event_queue_destroy || !_glfw.wl.client.proxy_marshal || !_glfw.wl.client.proxy_add_listener || !_glfw.wl.client.proxy_destroy || @@ -617,7 +635,10 @@ int _glfwInitWayland(void) !_glfw.wl.client.proxy_get_user_data || !_glfw.wl.client.proxy_set_user_data || !_glfw.wl.client.proxy_get_tag || - !_glfw.wl.client.proxy_set_tag) + !_glfw.wl.client.proxy_set_tag || + !_glfw.wl.client.proxy_create_wrapper || + !_glfw.wl.client.proxy_wrapper_destroy || + !_glfw.wl.client.proxy_set_queue) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to load libwayland-client entry point"); diff --git a/src/wl_platform.h b/src/wl_platform.h index 9bd3b0ef6..16b735d1d 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -51,6 +51,10 @@ typedef void (* PFN_wl_display_disconnect)(struct wl_display*); typedef int (* PFN_wl_display_roundtrip)(struct wl_display*); typedef int (* PFN_wl_display_get_fd)(struct wl_display*); typedef int (* PFN_wl_display_prepare_read)(struct wl_display*); +typedef struct wl_event_queue* (* PFN_wl_display_create_queue)(struct wl_display*); +typedef void (* PFN_wl_event_queue_destroy)(struct wl_event_queue*); +typedef int (* PFN_wl_display_prepare_read_queue)(struct wl_display*,struct wl_event_queue*); +typedef int (* PFN_wl_display_dispatch_queue_pending)(struct wl_display*,struct wl_event_queue*); typedef void (* PFN_wl_proxy_marshal)(struct wl_proxy*,uint32_t,...); typedef int (* PFN_wl_proxy_add_listener)(struct wl_proxy*,void(**)(void),void*); typedef void (* PFN_wl_proxy_destroy)(struct wl_proxy*); @@ -62,6 +66,9 @@ typedef void (* PFN_wl_proxy_set_tag)(struct wl_proxy*,const char*const*); typedef const char* const* (* PFN_wl_proxy_get_tag)(struct wl_proxy*); typedef uint32_t (* PFN_wl_proxy_get_version)(struct wl_proxy*); typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,uint32_t,...); +typedef void* (* PFN_wl_proxy_create_wrapper)(void*); +typedef void (* PFN_wl_proxy_wrapper_destroy)(void*); +typedef void (* PFN_wl_proxy_set_queue)(struct wl_proxy*,struct wl_event_queue*); #define wl_display_flush _glfw.wl.client.display_flush #define wl_display_cancel_read _glfw.wl.client.display_cancel_read #define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending @@ -70,6 +77,10 @@ typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_ #define wl_display_roundtrip _glfw.wl.client.display_roundtrip #define wl_display_get_fd _glfw.wl.client.display_get_fd #define wl_display_prepare_read _glfw.wl.client.display_prepare_read +#define wl_display_create_queue _glfw.wl.client.display_create_queue +#define wl_display_prepare_read_queue _glfw.wl.client.display_prepare_read_queue +#define wl_display_dispatch_queue_pending _glfw.wl.client.display_dispatch_queue_pending +#define wl_event_queue_destroy _glfw.wl.client.event_queue_destroy #define wl_proxy_marshal _glfw.wl.client.proxy_marshal #define wl_proxy_add_listener _glfw.wl.client.proxy_add_listener #define wl_proxy_destroy _glfw.wl.client.proxy_destroy @@ -81,6 +92,9 @@ typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_ #define wl_proxy_set_tag _glfw.wl.client.proxy_set_tag #define wl_proxy_get_version _glfw.wl.client.proxy_get_version #define wl_proxy_marshal_flags _glfw.wl.client.proxy_marshal_flags +#define wl_proxy_create_wrapper _glfw.wl.client.proxy_create_wrapper +#define wl_proxy_wrapper_destroy _glfw.wl.client.proxy_wrapper_destroy +#define wl_proxy_set_queue _glfw.wl.client.proxy_set_queue struct wl_shm; struct wl_output; @@ -364,7 +378,11 @@ typedef struct _GLFWwindowWayland struct wl_callback* callback; struct { + struct wl_event_queue* queue; struct wl_egl_window* window; + struct wl_callback* callback; + struct wl_surface* wrapper; + int interval; } egl; struct { @@ -537,6 +555,10 @@ typedef struct _GLFWlibraryWayland PFN_wl_display_roundtrip display_roundtrip; PFN_wl_display_get_fd display_get_fd; PFN_wl_display_prepare_read display_prepare_read; + PFN_wl_display_create_queue display_create_queue; + PFN_wl_display_prepare_read_queue display_prepare_read_queue; + PFN_wl_display_dispatch_queue_pending display_dispatch_queue_pending; + PFN_wl_event_queue_destroy event_queue_destroy; PFN_wl_proxy_marshal proxy_marshal; PFN_wl_proxy_add_listener proxy_add_listener; PFN_wl_proxy_destroy proxy_destroy; @@ -548,6 +570,9 @@ typedef struct _GLFWlibraryWayland PFN_wl_proxy_set_tag proxy_set_tag; PFN_wl_proxy_get_version proxy_get_version; PFN_wl_proxy_marshal_flags proxy_marshal_flags; + PFN_wl_proxy_create_wrapper proxy_create_wrapper; + PFN_wl_proxy_wrapper_destroy proxy_wrapper_destroy; + PFN_wl_proxy_set_queue proxy_set_queue; } client; struct { @@ -706,3 +731,5 @@ void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window); void _glfwAddSeatListenerWayland(struct wl_seat* seat); void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device); +GLFWbool _glfwWaitForEGLFrameWayland(_GLFWwindow* window); + diff --git a/src/wl_window.c b/src/wl_window.c index b9dbaa3b2..22d2f6ee4 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2296,6 +2296,18 @@ static const struct xdg_activation_token_v1_listener xdgActivationListener = xdgActivationHandleDone }; +static void callbackHandleFrame(void* userData, struct wl_callback* callback, uint32_t data) +{ + _GLFWwindow* window = userData; + wl_callback_destroy(callback); + window->wl.egl.callback = NULL; +} + +static const struct wl_callback_listener frameCallbackListener = +{ + callbackHandleFrame +}; + void _glfwAddSeatListenerWayland(struct wl_seat* seat) { wl_seat_add_listener(seat, &seatListener, NULL); @@ -2306,6 +2318,39 @@ void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device) wl_data_device_add_listener(device, &dataDeviceListener, NULL); } +GLFWbool _glfwWaitForEGLFrameWayland(_GLFWwindow* window) +{ + double timeout = 0.02; + + while (window->wl.egl.callback) + { + while (wl_display_prepare_read_queue(_glfw.wl.display, window->wl.egl.queue) != 0) + wl_display_dispatch_queue_pending(_glfw.wl.display, window->wl.egl.queue); + + if (!flushDisplay()) + { + wl_display_cancel_read(_glfw.wl.display); + return GLFW_FALSE; + } + + struct pollfd fd = { wl_display_get_fd(_glfw.wl.display), POLLIN }; + + if (!_glfwPollPOSIX(&fd, 1, &timeout)) + { + wl_display_cancel_read(_glfw.wl.display); + return GLFW_FALSE; + } + + wl_display_read_events(_glfw.wl.display); + wl_display_dispatch_queue_pending(_glfw.wl.display, window->wl.egl.queue); + } + + window->wl.egl.callback = wl_surface_frame(window->wl.egl.wrapper); + wl_callback_add_listener(window->wl.egl.callback, &frameCallbackListener, window); + + // If the window is hidden when the wait is over then don't swap + return window->wl.visible; +} ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// @@ -2334,6 +2379,27 @@ GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, return GLFW_FALSE; } + window->wl.egl.queue = wl_display_create_queue(_glfw.wl.display); + if (!window->wl.egl.queue) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create EGL frame queue"); + return GLFW_FALSE; + } + + window->wl.egl.wrapper = wl_proxy_create_wrapper(window->wl.surface); + if (!window->wl.egl.wrapper) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create surface wrapper"); + return GLFW_FALSE; + } + + wl_proxy_set_queue((struct wl_proxy*) window->wl.egl.wrapper, + window->wl.egl.queue); + + window->wl.egl.interval = 1; + if (!_glfwInitEGL()) return GLFW_FALSE; if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) @@ -2405,6 +2471,15 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window) if (window->wl.fallback.buffer) wl_buffer_destroy(window->wl.fallback.buffer); + if (window->wl.egl.callback) + wl_callback_destroy(window->wl.egl.callback); + + if (window->wl.egl.wrapper) + wl_proxy_wrapper_destroy(window->wl.egl.wrapper); + + if (window->wl.egl.queue) + wl_event_queue_destroy(window->wl.egl.queue); + if (window->wl.egl.window) wl_egl_window_destroy(window->wl.egl.window); From 50b0a135a5fce986039bc384d91d55bb76dc66d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 13 Mar 2026 14:09:04 +0100 Subject: [PATCH 093/112] Wayland: Fix deadlock causing timeout If the frame was processed by wl_display_dispatch_queue_pending, this would be treated as no frame having been received. Oops. This bug was introduced by fdd14e65b1c29e4e6df875fb5669ec00d6793531. --- src/wl_window.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wl_window.c b/src/wl_window.c index 22d2f6ee4..931d5672f 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2324,8 +2324,11 @@ GLFWbool _glfwWaitForEGLFrameWayland(_GLFWwindow* window) while (window->wl.egl.callback) { - while (wl_display_prepare_read_queue(_glfw.wl.display, window->wl.egl.queue) != 0) + if (wl_display_prepare_read_queue(_glfw.wl.display, window->wl.egl.queue) != 0) + { wl_display_dispatch_queue_pending(_glfw.wl.display, window->wl.egl.queue); + continue; + } if (!flushDisplay()) { From bb8048122a8ef5a12e60d2ab3c8586961ae2366c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 11 Mar 2026 19:52:04 +0100 Subject: [PATCH 094/112] Wayland: Fix glfwPostEmptyEvent leaking a proxy The client-side proxy of the callback from each call to wl_display_sync was never destroyed. Fixes #2836 --- CONTRIBUTORS.md | 1 + README.md | 1 + src/wl_window.c | 14 +++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9bfcdf86b..31361b86d 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -57,6 +57,7 @@ video tutorials. - Jason Daly - danhambleton - Jarrod Davis + - Aaron Day - decce - Olivier Delannoy - Paul R. Deppe diff --git a/README.md b/README.md index 0723e8352..1a0f36495 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Mouse wheel scroll distance was incorrect on some compositors - [Wayland] Bugfix: `glfwSwapBuffers` would halt with nonzero swap interval when window was suspended (#1350,#2582,#2640,#2719,#2723,#2800,#2827) + - [Wayland] Bugfix: `glfwPostEmptyEvent` would leak a callback proxy (#2836) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/wl_window.c b/src/wl_window.c index 931d5672f..ce4480753 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -199,6 +199,16 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) return buffer; } +static void callbackHandleDone(void* userData, struct wl_callback* callback, uint32_t data) +{ + wl_callback_destroy(callback); +} + +static const struct wl_callback_listener noopCallbackListener = +{ + callbackHandleDone +}; + static void createFallbackEdge(_GLFWwindow* window, _GLFWfallbackEdgeWayland* edge, struct wl_surface* parent, @@ -2930,7 +2940,9 @@ void _glfwWaitEventsTimeoutWayland(double timeout) void _glfwPostEmptyEventWayland(void) { - wl_display_sync(_glfw.wl.display); + struct wl_callback* callback = wl_display_sync(_glfw.wl.display); + wl_callback_add_listener(callback, &noopCallbackListener, NULL); + flushDisplay(); } From 3130c004e1a08a77a19f7490ce6b1e04dbda7510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 11 Mar 2026 18:23:52 +0100 Subject: [PATCH 095/112] Wayland: Fix missing flush in glfwHideWindow --- README.md | 1 + src/wl_window.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 1a0f36495..7e640c37a 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `glfwSwapBuffers` would halt with nonzero swap interval when window was suspended (#1350,#2582,#2640,#2719,#2723,#2800,#2827) - [Wayland] Bugfix: `glfwPostEmptyEvent` would leak a callback proxy (#2836) + - [Wayland] Bugfix: `glfwHideWindow` did not always send its request immediately - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/wl_window.c b/src/wl_window.c index ce4480753..468360fe7 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2726,6 +2726,8 @@ void _glfwHideWindowWayland(_GLFWwindow* window) wl_surface_attach(window->wl.surface, NULL, 0, 0); wl_surface_commit(window->wl.surface); + + flushDisplay(); } } From 1929088dd91c23dfaf01340ed697f78ce07b986a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 11 Mar 2026 18:44:20 +0100 Subject: [PATCH 096/112] Make the empty events test somewhat plausible The empty events test now makes slightly more plausible use of glfwPostEmptyEvent. As a side-effect, the test now also works as intended on Wayland. --- tests/empty.c | 105 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 30 deletions(-) diff --git a/tests/empty.c b/tests/empty.c index 72caccbdc..1b66bb8f3 100644 --- a/tests/empty.c +++ b/tests/empty.c @@ -23,7 +23,10 @@ // //======================================================================== // -// This test is intended to verify that posting of empty events works +// This test is intended to verify that the posting of empty events works. +// Background colors are produced on a secondary thread, which then wakes +// the main thread with glfwPostEmptyEvent when a new one is available. +// This allows the main thread to wait for events unconditionally. // //======================================================================== @@ -37,25 +40,53 @@ #include #include #include +#include -static volatile int running = GLFW_TRUE; +struct State +{ + mtx_t lock; + bool running; + bool needs_update; + int width; + int height; + float r, g, b; +}; static void error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); } +static void generate_color(struct State* state) +{ + const float r = (float) rand() / (float) RAND_MAX; + const float g = (float) rand() / (float) RAND_MAX; + const float b = (float) rand() / (float) RAND_MAX; + const float l = sqrtf(r * r + g * g + b * b); + + mtx_lock(&state->lock); + state->r = r / l; + state->g = g / l; + state->b = b / l; + state->needs_update = true; + mtx_unlock(&state->lock); +} + static int thread_main(void* data) { - struct timespec time; + struct State* const state = data; - while (running) + srand((unsigned int) time(NULL)); + + while (state->running) { + generate_color(state); + glfwPostEmptyEvent(); + + struct timespec time; clock_gettime(CLOCK_REALTIME, &time); time.tv_sec += 1; thrd_sleep(&time, NULL); - - glfwPostEmptyEvent(); } return 0; @@ -64,28 +95,38 @@ static int thread_main(void* data) 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); + glfwSetWindowShouldClose(window, true); } -static float nrand(void) +static void framebuffer_size_callback(GLFWwindow* window, int width, int height) { - return (float) rand() / (float) RAND_MAX; + struct State* const state = glfwGetWindowUserPointer(window); + + mtx_lock(&state->lock); + state->width = width; + state->height = height; + state->needs_update = true; + mtx_unlock(&state->lock); } int main(void) { - int result; - thrd_t thread; - GLFWwindow* window; + struct State state = { .running = true }; - srand((unsigned int) time(NULL)); + if (mtx_init(&state.lock, mtx_plain) != thrd_success) + { + glfwTerminate(); + exit(EXIT_FAILURE); + } + + generate_color(&state); glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); - window = glfwCreateWindow(640, 480, "Empty Event Test", NULL, NULL); + GLFWwindow* window = glfwCreateWindow(640, 480, "Empty Event Test", NULL, NULL); if (!window) { glfwTerminate(); @@ -95,8 +136,13 @@ int main(void) glfwMakeContextCurrent(window); gladLoadGL(glfwGetProcAddress); glfwSetKeyCallback(window, key_callback); + glfwSetWindowUserPointer(window, &state); + glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); + glfwGetFramebufferSize(window, &state.width, &state.height); - if (thrd_create(&thread, thread_main, NULL) != thrd_success) + thrd_t color_thread; + + if (thrd_create(&color_thread, thread_main, &state) != thrd_success) { fprintf(stderr, "Failed to create secondary thread\n"); @@ -104,28 +150,27 @@ int main(void) exit(EXIT_FAILURE); } - while (running) + while (!glfwWindowShouldClose(window)) { - int width, height; - float r = nrand(), g = nrand(), b = nrand(); - float l = (float) sqrt(r * r + g * g + b * b); + if (state.needs_update) + { + mtx_lock(&state.lock); + glViewport(0, 0, state.width, state.height); + glClearColor(state.r, state.g, state.b, 1.f); + state.needs_update = false; + mtx_unlock(&state.lock); - glfwGetFramebufferSize(window, &width, &height); - - glViewport(0, 0, width, height); - glClearColor(r / l, g / l, b / l, 1.f); - glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(window); + glClear(GL_COLOR_BUFFER_BIT); + glfwSwapBuffers(window); + } glfwWaitEvents(); - - if (glfwWindowShouldClose(window)) - running = GLFW_FALSE; } glfwHideWindow(window); - thrd_join(thread, &result); - glfwDestroyWindow(window); + state.running = false; + thrd_join(color_thread, NULL); + mtx_destroy(&state.lock); glfwTerminate(); exit(EXIT_SUCCESS); From 55fd451d5fd1c3a0b259100b6753522d2cb1a4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 25 Mar 2026 17:58:04 +0100 Subject: [PATCH 097/112] Wayland: Remove unused struct member The libdecor initialization sync callback was saved in the library struct but never meaningfully used. --- src/wl_init.c | 11 +++-------- src/wl_platform.h | 1 - 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 25ceba0d6..04af29b86 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -244,10 +244,7 @@ static void libdecorReadyCallback(void* userData, uint32_t time) { _glfw.wl.libdecor.ready = GLFW_TRUE; - - assert(_glfw.wl.libdecor.callback == callback); - wl_callback_destroy(_glfw.wl.libdecor.callback); - _glfw.wl.libdecor.callback = NULL; + wl_callback_destroy(callback); } static const struct wl_callback_listener libdecorReadyListener = @@ -881,10 +878,8 @@ int _glfwInitWayland(void) libdecor_dispatch(_glfw.wl.libdecor.context, 0); // Create sync point to "know" when libdecor is ready for use - _glfw.wl.libdecor.callback = wl_display_sync(_glfw.wl.display); - wl_callback_add_listener(_glfw.wl.libdecor.callback, - &libdecorReadyListener, - NULL); + struct wl_callback* callback = wl_display_sync(_glfw.wl.display); + wl_callback_add_listener(callback, &libdecorReadyListener, NULL); } } diff --git a/src/wl_platform.h b/src/wl_platform.h index 16b735d1d..8164150aa 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -595,7 +595,6 @@ typedef struct _GLFWlibraryWayland struct { void* handle; struct libdecor* context; - struct wl_callback* callback; GLFWbool ready; PFN_libdecor_new libdecor_new_; PFN_libdecor_unref libdecor_unref_; From 51683a6f1ca12cf29567a8f0850a05808f431a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Mar 2026 18:51:54 +0100 Subject: [PATCH 098/112] Use C99 booleans for Khronos API extensions --- src/glx_context.c | 24 +++++++++++----------- src/internal.h | 48 ++++++++++++++++++++++---------------------- src/vulkan.c | 16 +++++++-------- src/win32_platform.h | 24 +++++++++++----------- src/x11_platform.h | 24 +++++++++++----------- 5 files changed, 68 insertions(+), 68 deletions(-) diff --git a/src/glx_context.c b/src/glx_context.c index 3d98d2a03..f56f674e6 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -365,7 +365,7 @@ GLFWbool _glfwInitGLX(void) getProcAddressGLX("glXSwapIntervalEXT"); if (_glfw.glx.SwapIntervalEXT) - _glfw.glx.EXT_swap_control = GLFW_TRUE; + _glfw.glx.EXT_swap_control = true; } if (extensionSupportedGLX("GLX_SGI_swap_control")) @@ -374,7 +374,7 @@ GLFWbool _glfwInitGLX(void) getProcAddressGLX("glXSwapIntervalSGI"); if (_glfw.glx.SwapIntervalSGI) - _glfw.glx.SGI_swap_control = GLFW_TRUE; + _glfw.glx.SGI_swap_control = true; } if (extensionSupportedGLX("GLX_MESA_swap_control")) @@ -383,17 +383,17 @@ GLFWbool _glfwInitGLX(void) getProcAddressGLX("glXSwapIntervalMESA"); if (_glfw.glx.SwapIntervalMESA) - _glfw.glx.MESA_swap_control = GLFW_TRUE; + _glfw.glx.MESA_swap_control = true; } if (extensionSupportedGLX("GLX_ARB_multisample")) - _glfw.glx.ARB_multisample = GLFW_TRUE; + _glfw.glx.ARB_multisample = true; if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB")) - _glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE; + _glfw.glx.ARB_framebuffer_sRGB = true; if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB")) - _glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE; + _glfw.glx.EXT_framebuffer_sRGB = true; if (extensionSupportedGLX("GLX_ARB_create_context")) { @@ -401,23 +401,23 @@ GLFWbool _glfwInitGLX(void) getProcAddressGLX("glXCreateContextAttribsARB"); if (_glfw.glx.CreateContextAttribsARB) - _glfw.glx.ARB_create_context = GLFW_TRUE; + _glfw.glx.ARB_create_context = true; } if (extensionSupportedGLX("GLX_ARB_create_context_robustness")) - _glfw.glx.ARB_create_context_robustness = GLFW_TRUE; + _glfw.glx.ARB_create_context_robustness = true; if (extensionSupportedGLX("GLX_ARB_create_context_profile")) - _glfw.glx.ARB_create_context_profile = GLFW_TRUE; + _glfw.glx.ARB_create_context_profile = true; if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile")) - _glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE; + _glfw.glx.EXT_create_context_es2_profile = true; if (extensionSupportedGLX("GLX_ARB_create_context_no_error")) - _glfw.glx.ARB_create_context_no_error = GLFW_TRUE; + _glfw.glx.ARB_create_context_no_error = true; if (extensionSupportedGLX("GLX_ARB_context_flush_control")) - _glfw.glx.ARB_context_flush_control = GLFW_TRUE; + _glfw.glx.ARB_context_flush_control = true; return GLFW_TRUE; } diff --git a/src/internal.h b/src/internal.h index 56418c8df..fc3ceda59 100644 --- a/src/internal.h +++ b/src/internal.h @@ -807,22 +807,22 @@ struct _GLFWlibrary EGLint major, minor; GLFWbool prefix; - GLFWbool KHR_create_context; - GLFWbool KHR_create_context_no_error; - GLFWbool KHR_gl_colorspace; - GLFWbool KHR_get_all_proc_addresses; - GLFWbool KHR_context_flush_control; - GLFWbool EXT_client_extensions; - GLFWbool EXT_platform_base; - GLFWbool EXT_platform_x11; - GLFWbool EXT_platform_wayland; - GLFWbool EXT_present_opaque; - GLFWbool ANGLE_platform_angle; - GLFWbool ANGLE_platform_angle_opengl; - GLFWbool ANGLE_platform_angle_d3d; - GLFWbool ANGLE_platform_angle_vulkan; - GLFWbool ANGLE_platform_angle_metal; - GLFWbool MESA_platform_surfaceless; + bool KHR_create_context; + bool KHR_create_context_no_error; + bool KHR_gl_colorspace; + bool KHR_get_all_proc_addresses; + bool KHR_context_flush_control; + bool EXT_client_extensions; + bool EXT_platform_base; + bool EXT_platform_x11; + bool EXT_platform_wayland; + bool EXT_present_opaque; + bool ANGLE_platform_angle; + bool ANGLE_platform_angle_opengl; + bool ANGLE_platform_angle_d3d; + bool ANGLE_platform_angle_vulkan; + bool ANGLE_platform_angle_metal; + bool MESA_platform_surfaceless; void* handle; @@ -866,14 +866,14 @@ struct _GLFWlibrary void* handle; char* extensions[2]; PFN_vkGetInstanceProcAddr GetInstanceProcAddr; - GLFWbool KHR_surface; - GLFWbool KHR_win32_surface; - GLFWbool MVK_macos_surface; - GLFWbool EXT_metal_surface; - GLFWbool KHR_xlib_surface; - GLFWbool KHR_xcb_surface; - GLFWbool KHR_wayland_surface; - GLFWbool EXT_headless_surface; + bool KHR_surface; + bool KHR_win32_surface; + bool MVK_macos_surface; + bool EXT_metal_surface; + bool KHR_xlib_surface; + bool KHR_xcb_surface; + bool KHR_wayland_surface; + bool EXT_headless_surface; } vk; struct { diff --git a/src/vulkan.c b/src/vulkan.c index 03642a31b..b93a14a6f 100644 --- a/src/vulkan.c +++ b/src/vulkan.c @@ -163,21 +163,21 @@ GLFWbool _glfwInitVulkan(int mode) for (i = 0; i < count; i++) { if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0) - _glfw.vk.KHR_surface = GLFW_TRUE; + _glfw.vk.KHR_surface = true; else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0) - _glfw.vk.KHR_win32_surface = GLFW_TRUE; + _glfw.vk.KHR_win32_surface = true; else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0) - _glfw.vk.MVK_macos_surface = GLFW_TRUE; + _glfw.vk.MVK_macos_surface = true; else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0) - _glfw.vk.EXT_metal_surface = GLFW_TRUE; + _glfw.vk.EXT_metal_surface = true; else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0) - _glfw.vk.KHR_xlib_surface = GLFW_TRUE; + _glfw.vk.KHR_xlib_surface = true; else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0) - _glfw.vk.KHR_xcb_surface = GLFW_TRUE; + _glfw.vk.KHR_xcb_surface = true; else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0) - _glfw.vk.KHR_wayland_surface = GLFW_TRUE; + _glfw.vk.KHR_wayland_surface = true; else if (strcmp(ep[i].extensionName, "VK_EXT_headless_surface") == 0) - _glfw.vk.EXT_headless_surface = GLFW_TRUE; + _glfw.vk.EXT_headless_surface = true; } _glfw_free(ep); diff --git a/src/win32_platform.h b/src/win32_platform.h index 49cceba6d..5e9a66054 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -336,18 +336,18 @@ typedef struct _GLFWlibraryWGL PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT; PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB; PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; - GLFWbool EXT_swap_control; - GLFWbool EXT_colorspace; - GLFWbool ARB_multisample; - GLFWbool ARB_framebuffer_sRGB; - GLFWbool EXT_framebuffer_sRGB; - GLFWbool ARB_pixel_format; - GLFWbool ARB_create_context; - GLFWbool ARB_create_context_profile; - GLFWbool EXT_create_context_es2_profile; - GLFWbool ARB_create_context_robustness; - GLFWbool ARB_create_context_no_error; - GLFWbool ARB_context_flush_control; + bool EXT_swap_control; + bool EXT_colorspace; + bool ARB_multisample; + bool ARB_framebuffer_sRGB; + bool EXT_framebuffer_sRGB; + bool ARB_pixel_format; + bool ARB_create_context; + bool ARB_create_context_profile; + bool EXT_create_context_es2_profile; + bool ARB_create_context_robustness; + bool ARB_create_context_no_error; + bool ARB_context_flush_control; } _GLFWlibraryWGL; // Win32-specific per-window data diff --git a/src/x11_platform.h b/src/x11_platform.h index f3a037f1e..64915fca7 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -503,18 +503,18 @@ typedef struct _GLFWlibraryGLX PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT; PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA; PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB; - GLFWbool SGI_swap_control; - GLFWbool EXT_swap_control; - GLFWbool MESA_swap_control; - GLFWbool ARB_multisample; - GLFWbool ARB_framebuffer_sRGB; - GLFWbool EXT_framebuffer_sRGB; - GLFWbool ARB_create_context; - GLFWbool ARB_create_context_profile; - GLFWbool ARB_create_context_robustness; - GLFWbool EXT_create_context_es2_profile; - GLFWbool ARB_create_context_no_error; - GLFWbool ARB_context_flush_control; + bool SGI_swap_control; + bool EXT_swap_control; + bool MESA_swap_control; + bool ARB_multisample; + bool ARB_framebuffer_sRGB; + bool EXT_framebuffer_sRGB; + bool ARB_create_context; + bool ARB_create_context_profile; + bool ARB_create_context_robustness; + bool EXT_create_context_es2_profile; + bool ARB_create_context_no_error; + bool ARB_context_flush_control; } _GLFWlibraryGLX; // X11-specific per-window data From b00e6a8a88ad1b60c0a045e696301deb92c9a13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 30 Mar 2026 19:37:40 +0200 Subject: [PATCH 099/112] Update to actions/checkout@v5 from v4 This is necessary due to the deprecation of Node.js 20 on Github Action runners. --- .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 8ef9ed793..2dc797397 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: CC: clang CFLAGS: -Werror steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Install dependencies run: | sudo apt update @@ -57,7 +57,7 @@ jobs: MACOSX_DEPLOYMENT_TARGET: 10.11 CMAKE_OSX_ARCHITECTURES: x86_64;arm64 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - 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@v4 + - uses: actions/checkout@v5 - 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 6c397996b850f3f9b3176e0fee79f95152144405 Mon Sep 17 00:00:00 2001 From: halx99 Date: Sat, 16 May 2026 00:00:17 +0800 Subject: [PATCH 100/112] Fix Windows CI Closes #2863 --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2dc797397..1fb0834e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -74,8 +74,8 @@ jobs: - name: Build Cocoa shared library run: cmake --build build-cocoa-shared --parallel - build-windows-vs2022: - name: Windows (VS2022) + build-windows-msvc: + name: Windows (MSVC) runs-on: windows-latest timeout-minutes: 4 env: @@ -84,17 +84,17 @@ jobs: - uses: actions/checkout@v5 - 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 + run: cmake -B build-win32-shared-x86 -A Win32 -D BUILD_SHARED_LIBS=ON - name: Build Win32 shared x86 library run: cmake --build build-win32-shared-x86 --parallel - name: Configure Win32 static x64 library - run: cmake -B build-win32-static-x64 -G "Visual Studio 17 2022" -A x64 + run: cmake -B build-win32-static-x64 -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 + run: cmake -B build-win32-shared-x64 -A x64 -D BUILD_SHARED_LIBS=ON - name: Build Win32 shared x64 library run: cmake --build build-win32-shared-x64 --parallel From 0136febb1ef5d1e28d58707217eb3df1eb148fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 9 Jun 2026 21:51:15 +0200 Subject: [PATCH 101/112] Add credit Related to #2863 --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 31361b86d..26e040061 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -98,6 +98,7 @@ video tutorials. - Andrew Gutekanst - Stephen Gutekanst - Jonathan Hale + - halx99 - Daniel Hauser - hdf89shfdfs - Moritz Heinemann From 567b1ec2442d59525e24c19e8d413df6baf02496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 9 Jun 2026 21:20:23 +0200 Subject: [PATCH 102/112] Cocoa: Fix some key events not being emitted The key combinations Cmd+Period, Ctrl+Tab and Ctrl+Esc are not passed to the first responder as key events. This commit catches and claims these specific key events via the key equivalents mechanism and emits them from there instead. Closes #1362 Fixes #2278 --- CONTRIBUTORS.md | 2 ++ README.md | 2 ++ src/cocoa_window.m | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 26e040061..6b453e723 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -6,6 +6,7 @@ excludes other invaluable contributions like language bindings and text and video tutorials. - Bobyshev Alexander + - Alzathar - Laurent Aphecetche - Matt Arsenault - Takuro Ashie @@ -235,6 +236,7 @@ video tutorials. - Ed Ropple - Aleksey Rybalkin - Mikko Rytkönen + - saikyun - Riku Salminen - Yoshinori Sano - Brandon Schaefer diff --git a/README.md b/README.md index 7e640c37a..ed18b9507 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,8 @@ information on what to include when reporting a bug. - [Win32] Removed support for Windows XP and Vista (#2505) - [Cocoa] Added `QuartzCore` framework as link-time dependency - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) + - [Cocoa] Bugfix: Cmd+Period, Ctrl+Tab and Ctrl+Esc key events were not emitted + (#1362,#2278) - [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 diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 1769f79b4..610498080 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -599,6 +599,34 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods); } +- (BOOL)performKeyEquivalent:(NSEvent *)event +{ + // HACK: Some key combinations are consumed before reaching keyDown: + // so we claim those events and emit them here + const int key = translateKey([event keyCode]); + const int mods = translateFlags([event modifierFlags]); + + if (mods & GLFW_MOD_CONTROL) + { + if (key == GLFW_KEY_TAB || key == GLFW_KEY_ESCAPE) + { + _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods); + return YES; + } + } + + if (mods & GLFW_MOD_SUPER) + { + if (key == GLFW_KEY_PERIOD) + { + _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods); + return YES; + } + } + + return [super performKeyEquivalent:event]; +} + - (void)scrollWheel:(NSEvent *)event { double deltaX = [event scrollingDeltaX]; From de0c378aa253551d36eb5b681c34598a19efa0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Mr=C3=A1z?= Date: Tue, 3 Mar 2026 16:10:20 +0100 Subject: [PATCH 103/112] Wayland: Conditionally define _GNU_SOURCE This fixes a re-definition warning for the _GNU_SOURCE macro. Edited by elmindreda: code formatting, author credit Related to go-gl/glfw#359 Fixes #2833 --- CONTRIBUTORS.md | 1 + src/wl_window.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 6b453e723..9705af14f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -183,6 +183,7 @@ video tutorials. - Jon Morton - Pierre Moulon - Martins Mozeiko + - Tomáš Mráz - Pascal Muetschard - James Murphy - Julian Møller diff --git a/src/wl_window.c b/src/wl_window.c index 468360fe7..7d0a8309e 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -24,7 +24,9 @@ // //======================================================================== -#define _GNU_SOURCE +#if !defined(_GNU_SOURCE) + #define _GNU_SOURCE +#endif #include "internal.h" From 06406a00a014415faa382ff7aa65620552da1167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 22 May 2026 17:25:09 +0200 Subject: [PATCH 104/112] 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 8164150aa..47189f599 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -375,7 +375,6 @@ typedef struct _GLFWwindowWayland GLFWbool transparent; GLFWbool scaleFramebuffer; struct wl_surface* surface; - struct wl_callback* callback; struct { struct wl_event_queue* queue; From dc86d02ff1943bbceda72d4e89f9cf711bbd6ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 15 Jun 2026 18:06:36 +0200 Subject: [PATCH 105/112] Wayland: Fix some event types not being processed If there was already an event available in the Wayland queue, that event would be processed but other kinds of events (libdecor, key repeat, joystick connection, etc.) would not be. This commit restores the processing of all available events on every call to glfw*Events. It is partially based on #2842 by jadahl. Because some libdecor plugins also process non-Wayland events, without providing an fd for them, libdecor_dispatch is now called unconditionally. Fixes #2793 Closes #2795 Related to #2842 --- README.md | 2 ++ src/wl_window.c | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ed18b9507..90cf45e77 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,8 @@ information on what to include when reporting a bug. was suspended (#1350,#2582,#2640,#2719,#2723,#2800,#2827) - [Wayland] Bugfix: `glfwPostEmptyEvent` would leak a callback proxy (#2836) - [Wayland] Bugfix: `glfwHideWindow` did not always send its request immediately + - [Wayland] Bugfix: Some event types were not always processed by `glfwPollEvents` or + `glfwWait*Events` (#2793,#2795) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/wl_window.c b/src/wl_window.c index 7d0a8309e..221b3ccd9 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1375,24 +1375,27 @@ static void handleEvents(double* timeout) #endif GLFWbool event = GLFW_FALSE; - enum { DISPLAY_FD, KEYREPEAT_FD, CURSOR_FD, LIBDECOR_FD }; + enum { DISPLAY_FD, KEYREPEAT_FD, CURSOR_FD }; struct pollfd fds[] = { [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 } + [CURSOR_FD] = { _glfw.wl.cursorTimerfd, POLLIN } }; - if (_glfw.wl.libdecor.context) - fds[LIBDECOR_FD].fd = libdecor_get_fd(_glfw.wl.libdecor.context); - while (!event) { + if (_glfw.wl.libdecor.context) + { + // Dispatch unconditionally because it also processes non-Wayland events + if (libdecor_dispatch(_glfw.wl.libdecor.context, 0) > 0) + event = GLFW_TRUE; + } + while (wl_display_prepare_read(_glfw.wl.display) != 0) { if (wl_display_dispatch_pending(_glfw.wl.display) > 0) - return; + event = GLFW_TRUE; } // If an error other than EAGAIN happens, we have likely been disconnected @@ -1411,6 +1414,11 @@ static void handleEvents(double* timeout) return; } + double immediate = 0.0; + + if (event) + timeout = &immediate; + if (!_glfwPollPOSIX(fds, sizeof(fds) / sizeof(fds[0]), timeout)) { wl_display_cancel_read(_glfw.wl.display); @@ -1457,12 +1465,6 @@ static void handleEvents(double* timeout) if (read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats)) == 8) incrementCursorImage(); } - - if (fds[LIBDECOR_FD].revents & POLLIN) - { - if (libdecor_dispatch(_glfw.wl.libdecor.context, 0) > 0) - event = GLFW_TRUE; - } } } From e94108d9db5f3d5d464d186b9df688d33beb1e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 15 Jun 2026 18:58:30 +0200 Subject: [PATCH 106/112] Wayland: Fix undecorated libdecor frame creation In order to safely call libdecor_frame_set_visibility during window creation, a libdecor frame state was synthesized and committed. This commit instead postpones the call to libdecor_frame_set_visibility until after the frame state received by the frame configure event has been committed. This appears to be a more polite approach. Related to #2842 --- src/wl_init.c | 3 +++ src/wl_platform.h | 3 +++ src/wl_window.c | 14 ++++++-------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 04af29b86..e6da57822 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -798,6 +798,8 @@ int _glfwInitWayland(void) _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_unset_capabilities"); _glfw.wl.libdecor.libdecor_frame_set_visibility_ = (PFN_libdecor_frame_set_visibility) _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_set_visibility"); + _glfw.wl.libdecor.libdecor_frame_is_visible_ = (PFN_libdecor_frame_is_visible) + _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_is_visible"); _glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_ = (PFN_libdecor_frame_get_xdg_toplevel) _glfwPlatformGetModuleSymbol(_glfw.wl.libdecor.handle, "libdecor_frame_get_xdg_toplevel"); _glfw.wl.libdecor.libdecor_configuration_get_content_size_ = (PFN_libdecor_configuration_get_content_size) @@ -829,6 +831,7 @@ int _glfwInitWayland(void) !_glfw.wl.libdecor.libdecor_frame_set_capabilities_ || !_glfw.wl.libdecor.libdecor_frame_unset_capabilities_ || !_glfw.wl.libdecor.libdecor_frame_set_visibility_ || + !_glfw.wl.libdecor.libdecor_frame_is_visible_ || !_glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_ || !_glfw.wl.libdecor.libdecor_configuration_get_content_size_ || !_glfw.wl.libdecor.libdecor_configuration_get_window_state_ || diff --git a/src/wl_platform.h b/src/wl_platform.h index 47189f599..405ea6334 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -311,6 +311,7 @@ typedef void (* PFN_libdecor_frame_unset_maximized)(struct libdecor_frame*); typedef void (* PFN_libdecor_frame_set_capabilities)(struct libdecor_frame*,enum libdecor_capabilities); typedef void (* PFN_libdecor_frame_unset_capabilities)(struct libdecor_frame*,enum libdecor_capabilities); typedef void (* PFN_libdecor_frame_set_visibility)(struct libdecor_frame*,bool visible); +typedef bool (* PFN_libdecor_frame_is_visible)(struct libdecor_frame*); typedef struct xdg_toplevel* (* PFN_libdecor_frame_get_xdg_toplevel)(struct libdecor_frame*); typedef bool (* PFN_libdecor_configuration_get_content_size)(struct libdecor_configuration*,struct libdecor_frame*,int*,int*); typedef bool (* PFN_libdecor_configuration_get_window_state)(struct libdecor_configuration*,enum libdecor_window_state*); @@ -336,6 +337,7 @@ typedef void (* PFN_libdecor_state_free)(struct libdecor_state*); #define libdecor_frame_set_capabilities _glfw.wl.libdecor.libdecor_frame_set_capabilities_ #define libdecor_frame_unset_capabilities _glfw.wl.libdecor.libdecor_frame_unset_capabilities_ #define libdecor_frame_set_visibility _glfw.wl.libdecor.libdecor_frame_set_visibility_ +#define libdecor_frame_is_visible _glfw.wl.libdecor.libdecor_frame_is_visible_ #define libdecor_frame_get_xdg_toplevel _glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_ #define libdecor_configuration_get_content_size _glfw.wl.libdecor.libdecor_configuration_get_content_size_ #define libdecor_configuration_get_window_state _glfw.wl.libdecor.libdecor_configuration_get_window_state_ @@ -615,6 +617,7 @@ typedef struct _GLFWlibraryWayland PFN_libdecor_frame_set_capabilities libdecor_frame_set_capabilities_; PFN_libdecor_frame_unset_capabilities libdecor_frame_unset_capabilities_; PFN_libdecor_frame_set_visibility libdecor_frame_set_visibility_; + PFN_libdecor_frame_is_visible libdecor_frame_is_visible_; PFN_libdecor_frame_get_xdg_toplevel libdecor_frame_get_xdg_toplevel_; PFN_libdecor_configuration_get_content_size libdecor_configuration_get_content_size_; PFN_libdecor_configuration_get_window_state libdecor_configuration_get_window_state_; diff --git a/src/wl_window.c b/src/wl_window.c index 221b3ccd9..46f6d469e 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -896,6 +896,10 @@ void libdecorFrameHandleConfigure(struct libdecor_frame* frame, libdecor_frame_commit(frame, frameState, config); libdecor_state_free(frameState); + // NOTE: Frame visibility must only be set after a frame state has been committed + if (window->decorated != libdecor_frame_is_visible(window->wl.libdecor.frame)) + libdecor_frame_set_visibility(window->wl.libdecor.frame, window->decorated); + if (window->wl.activated != activated) { window->wl.activated = activated; @@ -977,11 +981,6 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) return GLFW_FALSE; } - struct libdecor_state* frameState = - libdecor_state_new(window->wl.width, window->wl.height); - libdecor_frame_commit(window->wl.libdecor.frame, frameState, NULL); - libdecor_state_free(frameState); - if (strlen(window->wl.appId)) libdecor_frame_set_app_id(window->wl.libdecor.frame, window->wl.appId); @@ -1017,12 +1016,11 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) } else { + // Frame visibility is applied in libdecorFrameHandleConfigure + if (window->wl.maximized) libdecor_frame_set_maximized(window->wl.libdecor.frame); - if (!window->decorated) - libdecor_frame_set_visibility(window->wl.libdecor.frame, false); - setIdleInhibitor(window, GLFW_FALSE); } From ed6452b13c76f7b4da216a9952bc7837aeb0f031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 30 Mar 2026 11:48:35 +0200 Subject: [PATCH 107/112] Wayland: Set the correct min/max size when non-resizable Libdecor is a thin wrapper around xdg_toplevel, and expects the same kind of information passed to it as if it was a xdg_toplevel. This includes the min/max size when non-resizable, which was set when using xdg_toplevel directly, but not when using libdecor. This fixes issues with min/max size missing when mapping a non-resizable window. Related to #2842 --- src/wl_window.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index 46f6d469e..c6abe433e 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -986,26 +986,34 @@ static GLFWbool createLibdecorFrame(_GLFWwindow* window) libdecor_frame_set_title(window->wl.libdecor.frame, window->title); - if (window->minwidth != GLFW_DONT_CARE && - window->minheight != GLFW_DONT_CARE) + if (window->resizable) { - libdecor_frame_set_min_content_size(window->wl.libdecor.frame, - window->minwidth, - window->minheight); - } + if (window->minwidth != GLFW_DONT_CARE && + window->minheight != GLFW_DONT_CARE) + { + libdecor_frame_set_min_content_size(window->wl.libdecor.frame, + window->minwidth, + window->minheight); + } - if (window->maxwidth != GLFW_DONT_CARE && - window->maxheight != GLFW_DONT_CARE) - { - libdecor_frame_set_max_content_size(window->wl.libdecor.frame, - window->maxwidth, - window->maxheight); + if (window->maxwidth != GLFW_DONT_CARE && + window->maxheight != GLFW_DONT_CARE) + { + libdecor_frame_set_max_content_size(window->wl.libdecor.frame, + window->maxwidth, + window->maxheight); + } } - - if (!window->resizable) + else { libdecor_frame_unset_capabilities(window->wl.libdecor.frame, LIBDECOR_ACTION_RESIZE); + libdecor_frame_set_min_content_size(window->wl.libdecor.frame, + window->wl.width, + window->wl.height); + libdecor_frame_set_max_content_size(window->wl.libdecor.frame, + window->wl.width, + window->wl.height); } if (window->monitor) From 463cf73610d911e8eff95ae345143137cf610be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 26 Jun 2026 16:53:18 +0200 Subject: [PATCH 108/112] Win32: Fix scancode for media keys Media key events were incorrectly reported with a scancode of 0x100. This is based on a snippet by dougbinks in #2625. Fixes #1768 Closes #2417 Fixes #2625 --- README.md | 1 + src/win32_window.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 90cf45e77..416de2add 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ information on what to include when reporting a bug. - Updated minimum CMake version to 3.16 (#2541) - Removed support for building with original MinGW (#2540) - [Win32] Removed support for Windows XP and Vista (#2505) + - [Win32] Bugfix: Media keys were reported with a scancode of 256 (#1768,#2417,#2625) - [Cocoa] Added `QuartzCore` framework as link-time dependency - [Cocoa] Removed support for OS X 10.10 Yosemite and earlier (#2506) - [Cocoa] Bugfix: Cmd+Period, Ctrl+Tab and Ctrl+Esc key events were not emitted diff --git a/src/win32_window.c b/src/win32_window.c index 6427a673e..8f83a9a08 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -711,11 +711,12 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l const int mods = getKeyMods(); scancode = (HIWORD(lParam) & (KF_EXTENDED | 0xff)); - if (!scancode) + if (!(scancode & 0xff)) { - // NOTE: Some synthetic key messages have a scancode of zero - // HACK: Map the virtual key back to a usable scancode - scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC); + // NOTE: Both media keys and the synthetic key messages from Windows + // Clipboard History are reported with a scancode of zero + // HACK: Map the virtual key to a scancode but preserve extended bit + scancode |= MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC); } // HACK: Alt+PrtSc has a different scancode than just PrtSc From b7ef2919b0dcecfe65fb2c9b90d4088b7997816d Mon Sep 17 00:00:00 2001 From: road2react <93143714+road2react@users.noreply.github.com> Date: Sat, 3 Jan 2026 20:24:53 -0800 Subject: [PATCH 109/112] Wayland: Fix rounding of fractional scale sizes The framebuffer size for fractional scale surfaces should be rounded to the closest integer, not truncated as is currently done. This implements the rounding formula that the discussions over at wayland-protocols item 132 and MR 309 appear to be converging on. Fixes #2713 Closes #2810 --- src/wl_window.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index c6abe433e..fd8553a56 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -478,8 +478,9 @@ static void resizeFramebuffer(_GLFWwindow* window) { if (window->wl.fractionalScale) { - window->wl.fbWidth = (window->wl.width * window->wl.scalingNumerator) / 120; - window->wl.fbHeight = (window->wl.height * window->wl.scalingNumerator) / 120; + // Round halfway away from zero per fractional-scale-v1 protocol spec + window->wl.fbWidth = (window->wl.width * window->wl.scalingNumerator + 60) / 120; + window->wl.fbHeight = (window->wl.height * window->wl.scalingNumerator + 60) / 120; } else { From 0984b4354a608ea58a6bd278caaf5ceaebf82658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 22 Jul 2026 16:43:10 +0200 Subject: [PATCH 110/112] Update changelog and add credit Related to #2713 Related to #2810 --- CONTRIBUTORS.md | 2 ++ README.md | 1 + 2 files changed, 3 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9705af14f..8a495a128 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -57,6 +57,7 @@ video tutorials. - Bill Currie - Jason Daly - danhambleton + - danijel1023 - Jarrod Davis - Aaron Day - decce @@ -230,6 +231,7 @@ video tutorials. - Philip Rideout - Eddie Ringle - Max Risuhin + - road2react - Joe Roback - Jorge Rodriguez - Jari Ronkainen diff --git a/README.md b/README.md index 416de2add..a9bc780df 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: `glfwHideWindow` did not always send its request immediately - [Wayland] Bugfix: Some event types were not always processed by `glfwPollEvents` or `glfwWait*Events` (#2793,#2795) + - [Wayland] Bugfix: Scaled framebuffer size was sometimes incorect (#2713,#2810) - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale From deeadd3c30185bf69f6c4ea86fba53b424a4a8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 24 Jul 2026 10:19:38 +0200 Subject: [PATCH 111/112] Tag remaining Git and CI plumbing export-ignore --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index 805f4036b..eba18332b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,5 @@ .gitattributes export-ignore .travis.yml export-ignore .appveyor.yml export-ignore +.mailmap export-ignore +.github export-ignore From d9d6f0f1f967807ffade6598ea9a631ebaf37a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 30 Jul 2026 17:06:11 +0200 Subject: [PATCH 112/112] Start 3.5.1 Due to a misconfigured tool, an incorrect 3.5.0 tag was briefly made available in the main Git repository. Thanks to the manual intervention of many packaging volunteers this has been almost entirely rolled back. To make sure this release supersedes the incorrect tag everywhere, the first release of GLFW 3.5 is named 3.5.1. There are no code changes other than the version patch number. Fixes #2758 --- CMakeLists.txt | 2 +- README.md | 4 ++++ docs/news.md | 8 ++++++++ include/GLFW/glfw3.h | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 063533c4e..cbc12be8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16...3.28 FATAL_ERROR) -project(GLFW VERSION 3.5.0 LANGUAGES C HOMEPAGE_URL "https://www.glfw.org/") +project(GLFW VERSION 3.5.1 LANGUAGES C HOMEPAGE_URL "https://www.glfw.org/") set_property(GLOBAL PROPERTY USE_FOLDERS ON) diff --git a/README.md b/README.md index a9bc780df..c37d1deb5 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,10 @@ guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for information on what to include when reporting a bug. +## Changelog since 3.5 + +None. + ## Changelog since 3.4 - Added `GLFW_UNLIMITED_MOUSE_BUTTONS` input mode that allows mouse buttons beyond diff --git a/docs/news.md b/docs/news.md index f752ce427..e7e108bd3 100644 --- a/docs/news.md +++ b/docs/news.md @@ -3,6 +3,14 @@ [TOC] +## Why was there no 3.5.0 release? + +Due to a misconfigured tool, an incorrect `3.5.0` tag was briefly made available in the +main Git repository. Thanks to the manual intervention of many packaging volunteers this +has been almost entirely rolled back. To make sure the first actual release of GLFW 3.5 +replaces the incorrect tag everywhere, the first release is named 3.5.1. + + ## New features {#features} ### Unlimited mouse buttons {#unlimited_mouse_buttons} diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 16689a945..dec570024 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -298,7 +298,7 @@ extern "C" { * release is made that does not contain any API changes. * @ingroup init */ -#define GLFW_VERSION_REVISION 0 +#define GLFW_VERSION_REVISION 1 /*! @} */ /*! @brief One.