diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e980c547..8ef9ed79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,7 +54,7 @@ jobs: timeout-minutes: 4 env: CFLAGS: -Werror - MACOSX_DEPLOYMENT_TARGET: 10.8 + MACOSX_DEPLOYMENT_TARGET: 10.11 CMAKE_OSX_ARCHITECTURES: x86_64;arm64 steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 9d2d504b..8ed24d98 100644 --- a/.gitignore +++ b/.gitignore @@ -57,11 +57,11 @@ src/glfw3ConfigVersion.cmake # Compiled binaries src/libglfw.so src/libglfw.so.3 -src/libglfw.so.3.4 +src/libglfw.so.3.5 src/libglfw.dylib src/libglfw.dylib src/libglfw.3.dylib -src/libglfw.3.4.dylib +src/libglfw.3.5.dylib src/libglfw3.a src/glfw3.lib src/glfw3.dll diff --git a/CMakeLists.txt b/CMakeLists.txt index f0904b7e..830f8fd9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ -cmake_minimum_required(VERSION 3.4...3.20 FATAL_ERROR) +cmake_minimum_required(VERSION 3.4...3.28 FATAL_ERROR) -project(GLFW VERSION 3.4.0 LANGUAGES C) +project(GLFW VERSION 3.5.0 LANGUAGES C) if (POLICY CMP0069) cmake_policy(SET CMP0069 NEW) @@ -29,7 +29,7 @@ endif() if (DEFINED GLFW_USE_WAYLAND AND UNIX AND NOT APPLE) message(FATAL_ERROR - "GLFW_USE_WAYLAND has been removed; set the GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 options") + "GLFW_USE_WAYLAND has been removed; delete the CMake cache and set GLFW_BUILD_WAYLAND and GLFW_BUILD_X11 instead") endif() cmake_dependent_option(GLFW_BUILD_WIN32 "Build support for Win32" ON "WIN32" OFF) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4c94de63..5a410d7f 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 @@ -48,6 +49,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 0b78c3b5..cb26aaf2 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ GLFW is licensed under the [zlib/libpng license](https://www.glfw.org/license.html). You can [download](https://www.glfw.org/download.html) the latest stable release -as source or Windows binaries, or fetch the `latest` branch from GitHub. Each -release starting with 3.0 also has a corresponding [annotated -tag](https://github.com/glfw/glfw/releases) with source and binary archives. +as source or Windows binaries. Each release starting with 3.0 also has +a corresponding [annotated tag](https://github.com/glfw/glfw/releases) with +source and binary archives. The [documentation](https://www.glfw.org/docs/latest/) is available online and is included in all source and binary archives. See the [release @@ -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. @@ -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 @@ -119,328 +119,22 @@ guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for information on what to include when reporting a bug. -## Changelog since 3.3.9 +## Changelog since 3.4 - - 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.1 - - 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 - - [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) + - 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) + - [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 + `GLFW_NATIVE_CONTEXT_API` (#2518) - Added `GLFW_ACCELERATION` window hint for hardware acceleration (#2491) -## 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 - - ## Contact On [glfw.org](https://www.glfw.org/) you can find the latest version of GLFW, as diff --git a/docs/build.md b/docs/build.md index d00d676e..7b0f8bfe 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. @@ -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/docs/compat.md b/docs/compat.md index ef64b0cc..5072d5c1 100644 --- a/docs/compat.md +++ b/docs/compat.md @@ -242,24 +242,27 @@ extensions are unavailable, the `GLFW_SRGB_CAPABLE` hint will have no effect. ## OpenGL on macOS {#compat_osx} -Support for OpenGL 3.2 and above was introduced with OS X 10.7 and even then -only forward-compatible, core profile contexts are supported. Support for -OpenGL 4.1 was introduced with OS X 10.9, also limited to forward-compatible, -core profile contexts. There is also still no mechanism for requesting debug -contexts or no-error contexts. Versions of Mac OS X earlier than 10.7 support -at most OpenGL version 2.1. +macOS (as of version 14) still provides OpenGL but it has been deprecated by +Apple. While the API is still available, it is poorly maintained and frequently +develops new issues. On modern systems, OpenGL is implemented on top of Metal +and is not fully thread-safe. -Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and -`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if -given version 3.0 or 3.1. The `GLFW_OPENGL_PROFILE` hint must be set to -`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The -`GLFW_CONTEXT_DEBUG` and `GLFW_CONTEXT_NO_ERROR` hints are ignored. +macOS does not support OpenGL stereo rendering. If the `GLFW_STEREO` hint is +set to true, OpenGL context creation will always fail. -Also, on Mac OS X 10.6 and below, the `GLFW_CONTEXT_VERSION_MAJOR` and -`GLFW_CONTEXT_VERSION_MINOR` hints will fail if given a version above 2.1, -setting the `GLFW_OPENGL_PROFILE` or `GLFW_OPENGL_FORWARD_COMPAT` hints to -a non-default value will cause @ref glfwCreateWindow to fail and the -`GLFW_CONTEXT_DEBUG` hint is ignored. +macOS only supports OpenGL core profile contexts that are forward-compatible, +but the `GLFW_OPENGL_FORWARD_COMPAT` hint is ignored since GLFW 3.4. Even if +this hint is set to false (the default), a forward-compatible context will be +returned if available. + +macOS does not support OpenGL debug contexts, no-error contexts or robustness. +The `GLFW_CONTEXT_DEBUG`, `GLFW_CONTEXT_NO_ERROR` and `GLFW_CONTEXT_ROBUSTNESS` +hints will be ignored and a context without these features will be returned. + +macOS does not flush OpenGL contexts when they are made non-current. The +`GLFW_CONTEXT_RELEASE_BEHAVIOR` hint is ignored and the release behavior will +always be the equivalent of `GLFW_RELEASE_BEHAVIOR_NONE`. If you need a context +to be flushed, call `glFlush` before making it non-current. ## Vulkan loader and API {#compat_vulkan} diff --git a/docs/extra.css b/docs/extra.css index 1a287343..7eb7e9d9 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -1,2 +1,2 @@ -.sm-dox,.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted,.sm-dox ul a:hover{background:none;text-shadow:none}.sm-dox a span.sub-arrow{border-color:#f2f2f2 transparent transparent transparent}.sm-dox a span.sub-arrow:active,.sm-dox a span.sub-arrow:focus,.sm-dox a span.sub-arrow:hover,.sm-dox a:hover span.sub-arrow{border-color:#f60 transparent transparent transparent}.sm-dox ul a span.sub-arrow:active,.sm-dox ul a span.sub-arrow:focus,.sm-dox ul a span.sub-arrow:hover,.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent #f60}.sm-dox ul a:hover{background:#666;text-shadow:none}.sm-dox ul.sm-nowrap a{color:#4d4d4d;text-shadow:none}#main-nav,#main-menu,#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code,.markdownTable code{background:none}#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,table.markdownTable td,table.markdownTable th,hr,.memSeparator{border:none}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.reflist dt a.el,.levels span,.directory .levels span{text-shadow:none}.memdoc,dl.reflist dd{box-shadow:none}div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code,table.markdownTable code{padding:0}#nav-path,.directory .levels,span.lineno{display:none}html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),tr.markdownTableBody:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code,.markdownTableRowEven{background:#f2f2f2}body{color:#4d4d4d}div.title{font-size:170%;margin:1em 0 0.5em 0}h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em{color:#1a1a1a;border-bottom:none}h1{padding-top:0.5em;font-size:150%}h2{padding-top:0.5em;margin-bottom:0;font-size:130%}h3{padding-top:0.5em;margin-bottom:0;font-size:110%}.glfwheader{font-size:16px;min-height:64px;max-width:920px;padding:0 32px;margin:0 auto;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#glfwhome{line-height:64px;padding-right:48px;color:#666;font-size:2.5em;background:url("https://www.glfw.org/css/arrow.png") no-repeat right}.glfwnavbar{list-style-type:none;margin:0 0 0 auto;float:right}#glfwhome,.glfwnavbar li{float:left}.glfwnavbar a,.glfwnavbar a:visited{line-height:64px;margin-left:2em;display:block;color:#666}.glfwnavbar{padding-left:0}#glfwhome,.glfwnavbar a,.glfwnavbar a:visited{transition:.35s ease}#titlearea,.footer{color:#666}address.footer{text-align:center;padding:2em;margin-top:3em}#top{background:#666}#main-nav{max-width:960px;margin:0 auto;font-size:13px}#main-menu{max-width:920px;margin:0 auto;font-size:13px}.memtitle{display:none}.memproto,.memname{font-weight:bold;text-shadow:none}#main-menu{min-height:36px;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li{color:#f2f2f2}#main-menu li ul.sm-nowrap li a{color:#4d4d4d}#main-menu li ul.sm-nowrap li a:hover{color:#f60}#main-menu>li:last-child{margin:0 0 0 auto}.contents{min-height:590px}div.contents,div.header{max-width:920px;margin:0 auto;padding:0 32px;background:#fff none}table.doxtable th,table.markdownTable th,dl.reflist dt{background:linear-gradient(to bottom, #ffa733 0%, #f60 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;text-align:left;color:#fff}dl.reflist dt a.el{color:#f60;padding:.2em;border-radius:4px;background-color:#ffe0cc}div.toc{float:right;width:35%}@media screen and (max-width: 600px){div.toc{float:none;width:inherit;margin:0}}div.toc h3{font-size:1.17em}div.toc ul{padding-left:1.5em}div.toc li{font-size:1em;padding-left:0;list-style-type:disc}div.toc li.level2,div.toc li.level3{margin-left:0.5em}div.toc,.memproto,div.qindex,div.ah{background:linear-gradient(to bottom, #f2f2f2 0%, #e6e6e6 100%);box-shadow:inset 0 0 32px #e6e6e6;text-shadow:0 1px 1px #fff;color:#1a1a1a;border:2px solid #e6e6e6;border-radius:4px}.paramname{color:#803300}dl.reflist dt{border:2px solid #f60;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:none}dl.reflist dd{border:2px solid #f60;border-bottom-right-radius:4px;border-bottom-left-radius:4px;border-top:none}table.doxtable,table.markdownTable{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,#main-menu a:hover,span.lineno a:hover{color:#f60;text-decoration:none}div.directory{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}hr,.memSeparator{height:2px;background:linear-gradient(to right, #f2f2f2 0%, #d9d9d9 50%, #f2f2f2 100%)}dl.note,dl.pre,dl.post,dl.invariant{background:linear-gradient(to bottom, #ddfad1 0%, #cbf7ba 100%);box-shadow:inset 0 0 32px #baf5a3;color:#1e5309;border:2px solid #afe699}dl.warning,dl.attention{background:linear-gradient(to bottom, #fae8d1 0%, #f7ddba 100%);box-shadow:inset 0 0 32px #f5d1a3;color:#533309;border:2px solid #e6c499}dl.deprecated,dl.bug{background:linear-gradient(to bottom, #fad1e3 0%, #f7bad6 100%);box-shadow:inset 0 0 32px #f5a3c8;color:#53092a;border:2px solid #e699bb}dl.todo,dl.test{background:linear-gradient(to bottom, #d1ecfa 0%, #bae3f7 100%);box-shadow:inset 0 0 32px #a3daf5;color:#093a53;border:2px solid #99cce6}dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test{border-radius:4px;padding:1em;text-shadow:0 1px 1px #fff;margin:1em 0}.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited{color:inherit}div.line{line-height:inherit}div.fragment,pre.fragment{background:#f2f2f2;border-radius:4px;border:none;padding:1em;overflow:auto;border-left:4px solid #ccc;margin:1em 0}.lineno a,.lineno a:visited,.line,pre.fragment{color:#4d4d4d}span.preprocessor,span.comment{color:#007899}a.code,a.code:visited{color:#e64500}span.keyword,span.keywordtype,span.keywordflow{color:#404040;font-weight:bold}span.stringliteral{color:#360099}code{padding:.1em;border-radius:4px} +.sm-dox,.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted,.sm-dox ul a:hover{background:none;text-shadow:none}.sm-dox a span.sub-arrow{border-color:#f2f2f2 transparent transparent transparent}.sm-dox a span.sub-arrow:active,.sm-dox a span.sub-arrow:focus,.sm-dox a span.sub-arrow:hover,.sm-dox a:hover span.sub-arrow{border-color:#f60 transparent transparent transparent}.sm-dox ul a span.sub-arrow:active,.sm-dox ul a span.sub-arrow:focus,.sm-dox ul a span.sub-arrow:hover,.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent #f60}.sm-dox ul a:hover{background:#666;text-shadow:none}.sm-dox ul.sm-nowrap a{color:#4d4d4d;text-shadow:none}#main-nav,#main-menu,#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.memdoc,dl.reflist dd,div.toc li,.ah,span.lineno,span.lineno a,span.lineno a:hover,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,.doxtable code,.markdownTable code{background:none}#titlearea,.footer,.contents,div.header,.memdoc,table.doxtable td,table.doxtable th,table.markdownTable td,table.markdownTable th,hr,.memSeparator{border:none}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li,.reflist dt a.el,.levels span,.directory .levels span{text-shadow:none}.memdoc,dl.reflist dd{box-shadow:none}div.headertitle,.note code,.pre code,.post code,.invariant code,.warning code,.attention code,.deprecated code,.bug code,.todo code,.test code,table.doxtable code,table.markdownTable code{padding:0}#nav-path,.directory .levels,span.lineno{display:none}html,#titlearea,.footer,tr.even,.directory tr.even,.doxtable tr:nth-child(even),tr.markdownTableBody:nth-child(even),.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,code,.markdownTableRowEven{background:#f2f2f2}body{color:#4d4d4d}div.title{font-size:170%;margin:1em 0 0.5em 0}h1,h2,h2.groupheader,h3,div.toc h3,h4,h5,h6,strong,em{color:#1a1a1a;border-bottom:none}h1{padding-top:0.5em;font-size:150%}h2{padding-top:0.5em;margin-bottom:0;font-size:130%}h3{padding-top:0.5em;margin-bottom:0;font-size:110%}.glfwheader{font-size:16px;min-height:64px;max-width:920px;padding:0 32px;margin:0 auto;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#glfwhome{line-height:64px;padding-right:48px;color:#666;font-size:2.5em;background:url("https://www.glfw.org/css/arrow.png") no-repeat right}.glfwnavbar{list-style-type:none;margin:0 0 0 auto;float:right}#glfwhome,.glfwnavbar li{float:left}.glfwnavbar a,.glfwnavbar a:visited{line-height:64px;margin-left:2em;display:block;color:#666}.glfwnavbar{padding-left:0}#glfwhome,.glfwnavbar a,.glfwnavbar a:visited{transition:.35s ease}#titlearea,.footer{color:#666}address.footer{text-align:center;padding:2em;margin-top:3em}#top{background:#666}#main-nav{max-width:960px;margin:0 auto;font-size:13px}#main-menu{max-width:920px;margin:0 auto;font-size:13px}.memtitle{display:none}.memproto,.memname{font-weight:bold;text-shadow:none}#main-menu{min-height:36px;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-items:center;align-content:stretch}#main-menu a:focus{outline-style:none}#main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li{color:#f2f2f2}#main-menu li ul.sm-nowrap li a{color:#4d4d4d}#main-menu li ul.sm-nowrap li a:hover{color:#f60}#main-menu>li:last-child{margin:0 0 0 auto}.contents{min-height:590px}div.contents,div.header{max-width:920px;margin:0 auto;padding:0 32px;background:#fff none}table.doxtable th,table.markdownTable th,dl.reflist dt{background:linear-gradient(to bottom, #ffa733 0%, #f60 100%);box-shadow:inset 0 0 32px #f60;text-shadow:0 -1px 1px #b34700;text-align:left;color:#fff}dl.reflist dt a.el{color:#f60;padding:.2em;border-radius:4px;background-color:#ffe0cc}div.toc{float:right;width:35%}@media screen and (max-width: 600px){div.toc{float:none;width:inherit;margin:0}}div.toc h3{font-size:1.17em}div.toc ul{padding-left:1.5em}div.toc li{font-size:1em;padding-left:0;list-style-type:disc}div.toc li.level2,div.toc li.level3{margin-left:0.5em}div.toc,.memproto,div.qindex,div.ah{background:linear-gradient(to bottom, #f2f2f2 0%, #e6e6e6 100%);box-shadow:inset 0 0 32px #e6e6e6;text-shadow:0 1px 1px #fff;color:#1a1a1a;border:2px solid #e6e6e6;border-radius:4px}.paramname{color:#803300}dl.reflist dt{border:2px solid #f60;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:none}dl.reflist dd{border:2px solid #f60;border-bottom-right-radius:4px;border-bottom-left-radius:4px;border-top:none}table.doxtable,table.markdownTable{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}a,a:hover,a:visited,a:visited:hover,.contents a:visited,.el,a.el:visited,#glfwhome:hover,#main-menu a:hover,span.lineno a:hover{color:#f60;text-decoration:none}div.directory{border-collapse:inherit;border-spacing:0;border:2px solid #f60;border-radius:4px}hr,.memSeparator{height:2px;background:linear-gradient(to right, #f2f2f2 0%, #d9d9d9 50%, #f2f2f2 100%)}dl.note,dl.pre,dl.post,dl.invariant{background:linear-gradient(to bottom, #ddfad1 0%, #cbf7ba 100%);box-shadow:inset 0 0 32px #baf5a3;color:#1e5309;border:2px solid #afe699}dl.warning,dl.attention{background:linear-gradient(to bottom, #fae8d1 0%, #f7ddba 100%);box-shadow:inset 0 0 32px #f5d1a3;color:#533309;border:2px solid #e6c499}dl.deprecated,dl.bug{background:linear-gradient(to bottom, #fad1e3 0%, #f7bad6 100%);box-shadow:inset 0 0 32px #f5a3c8;color:#53092a;border:2px solid #e699bb}dl.todo,dl.test{background:linear-gradient(to bottom, #d1ecfa 0%, #bae3f7 100%);box-shadow:inset 0 0 32px #a3daf5;color:#093a53;border:2px solid #99cce6}dl.note,dl.pre,dl.post,dl.invariant,dl.warning,dl.attention,dl.deprecated,dl.bug,dl.todo,dl.test{border-radius:4px;padding:1em;text-shadow:0 1px 1px #fff;margin:1em 0}.note a,.pre a,.post a,.invariant a,.warning a,.attention a,.deprecated a,.bug a,.todo a,.test a,.note a:visited,.pre a:visited,.post a:visited,.invariant a:visited,.warning a:visited,.attention a:visited,.deprecated a:visited,.bug a:visited,.todo a:visited,.test a:visited{color:inherit}div.line{line-height:inherit}div.fragment,pre.fragment{background:#f2f2f2;border-radius:4px;border:none;padding:1em;overflow:auto;border-left:4px solid #ccc;margin:1em 0}.lineno a,.lineno a:visited,.line,pre.fragment{color:#4d4d4d}span.preprocessor,span.comment{color:#007899}a.code,a.code:visited{color:#e64500}span.keyword,span.keywordtype,span.keywordflow{color:#404040;font-weight:bold}span.stringliteral{color:#360099}code{padding:.1em;border-radius:4px} /*# sourceMappingURL=extra.css.map */ diff --git a/docs/extra.css.map b/docs/extra.css.map index 4d9333c2..d9a5d7d3 100644 --- a/docs/extra.css.map +++ b/docs/extra.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "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", +"mappings": "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", "sources": ["extra.scss"], "names": [], "file": "extra.css" diff --git a/docs/extra.scss b/docs/extra.scss index 43fe9831..acf28e21 100644 --- a/docs/extra.scss +++ b/docs/extra.scss @@ -255,6 +255,10 @@ address.footer { align-content: stretch; } +#main-menu a:focus { + outline-style: none; +} + #main-menu a,#main-menu a:visited,#main-menu a:hover,#main-menu li { color:$navbar-link-color; } diff --git a/docs/input.md b/docs/input.md index 56983b08..3ef1aebe 100644 --- a/docs/input.md +++ b/docs/input.md @@ -492,6 +492,20 @@ a mouse button callback. glfwSetMouseButtonCallback(window, mouse_button_callback); ``` +@anchor GLFW_UNLIMITED_MOUSE_BUTTONS +To handle all mouse buttons in the callback, instead of only ones with associated +[button tokens](@ref buttons), set the @ref GLFW_UNLIMITED_MOUSE_BUTTONS +input mode. + +```c +glfwSetInputMode(window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE); +``` + +When this input mode is enabled, GLFW doesn't limit the reported mouse buttons +to only those that have an associated button token, for compatibility with +earlier versions of GLFW, which never reported any buttons over +@ref GLFW_MOUSE_BUTTON_LAST, on which users could have relied on. + The callback function receives the [mouse button](@ref buttons), button action and [modifier bits](@ref mods). @@ -503,11 +517,16 @@ void mouse_button_callback(GLFWwindow* window, int button, int action, int mods) } ``` +The mouse button is an integer that can be one of the +[mouse button tokens](@ref buttons) or, if the +@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode is set, any other positive value. + The action is one of `GLFW_PRESS` or `GLFW_RELEASE`. -The last reported state for every [supported mouse button](@ref buttons) is also +The last reported state for every [mouse button token](@ref buttons) is also saved in per-window state arrays that can be polled with @ref -glfwGetMouseButton. +glfwGetMouseButton. This is not effected by the @ref GLFW_UNLIMITED_MOUSE_BUTTONS +input mode. ```c int state = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT); @@ -540,7 +559,7 @@ had been processed in the meantime, the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`. The `GLFW_MOUSE_BUTTON_LAST` constant holds the highest value of any -[supported mouse button](@ref buttons). +[mouse button token](@ref buttons). ### Scroll input {#scrolling} diff --git a/docs/intro.md b/docs/intro.md index 0610202f..7aa75e31 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -621,17 +621,17 @@ The format of the string is as follows: - The names of the always supported context creation APIs EGL and OSMesa - Any additional compile-time options, APIs and (on Windows) what compiler was used -For example, compiling GLFW 3.4 with MinGW as a DLL for Windows, may result in a version string +For example, compiling GLFW 3.5 with MinGW as a DLL for Windows, may result in a version string like this: ```c -3.4.0 Win32 WGL Null EGL OSMesa MinGW DLL +3.5.0 Win32 WGL Null EGL OSMesa MinGW DLL ``` Compiling GLFW as a static library for Linux, with both Wayland and X11 enabled, may result in a version string like this: ```c -3.4.0 Wayland X11 GLX Null EGL OSMesa monotonic +3.5.0 Wayland X11 GLX Null EGL OSMesa monotonic ``` diff --git a/docs/main.md b/docs/main.md index 4f86b8af..c70f735f 100644 --- a/docs/main.md +++ b/docs/main.md @@ -4,7 +4,7 @@ GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan application development. It provides a simple, platform-independent API for creating windows, contexts and surfaces, reading input, handling events, etc. -@ref news_34 list new features, caveats and deprecations. +@ref news list new features, caveats and deprecations. @ref quick_guide is a guide for users new to GLFW. It takes you through how to write a small but complete program. @@ -29,9 +29,6 @@ use the new API. There is a section on @ref guarantees_limitations for pointer lifetimes, reentrancy, thread safety, event order and backward and forward compatibility. -The [FAQ](https://www.glfw.org/faq.html) answers many common questions about the -design, implementation and use of GLFW. - Finally, @ref compat_guide explains what APIs, standards and protocols GLFW uses and what happens when they are not present on a given machine. diff --git a/docs/news.md b/docs/news.md index b352d23e..c332f94a 100644 --- a/docs/news.md +++ b/docs/news.md @@ -1,147 +1,20 @@ -# Release notes {#news} +# Release notes for version 3.5 {#news} [TOC] -## Release notes for version 3.4 {#news_34} +## New features {#features} -### New features in version 3.4 {#features_34} +### Unlimited mouse buttons {#unlimited_mouse_buttons} -#### Cocoa NSView native access function {#native_cocoa_nsview_34} +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. -GLFW now provides the @ref glfwGetCocoaView native access function -for returning the Cocoa NSView. - - -#### Runtime platform selection {#runtime_platform_34} - -GLFW now supports being compiled for multiple backends and selecting between -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. - - -#### More standard cursor shapes {#standard_cursors_34} - -GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and -@ref GLFW_RESIZE_NESW_CURSOR for diagonal resizing, @ref GLFW_RESIZE_ALL_CURSOR -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_passthrough_34} - -GLFW now provides the [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_hint) -window hint for making a window transparent to mouse input, lettings events pass -to whatever window is behind it. This can also be changed after window -creation with the matching [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib). - - -#### Ability to get window title {#features_34_window_title} - -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_34} - -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 {#features_34_init_allocator} - -GLFW now supports plugging a custom memory allocator at initialization with @ref -glfwInitAllocator. The allocator is a struct of type @ref GLFWallocator with -function pointers corresponding to the standard library functions `malloc`, -`realloc` and `free`. - -For more information see @ref init_allocator. - - -#### Window hint for framebuffer scaling {#scale_framebuffer_34} - -GLFW now allows provides the -[GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint) window hint for -controlling framebuffer scaling on platforms that handle scaling by keeping the -window size the same while resizing the framebuffer. The default value is to -allow framebuffer scaling. - -This was already possible on macOS via the -[GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) window -hint. This hint is now another name for -[GLFW_SCALE_FRAMEBUFFER](@ref GLFW_SCALE_FRAMEBUFFER_hint). - -For more information see @ref window_scale. - - -#### Window hints for initial window position {#features_34_position_hint} - -GLFW now provides the @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y window hints for -specifying the initial position of the window. This removes the need to create a hidden -window, move it and then show it. The default value of these hints is -`GLFW_ANY_POSITION`, which selects the previous behavior. - -For more information see @ref window_pos. - - -#### Support for keyboard access to Windows window menu {#features_34_win32_keymenu} - -GLFW now provides the -[GLFW_WIN32_KEYBOARD_MENU](@ref GLFW_WIN32_KEYBOARD_MENU_hint) window hint for -enabling keyboard access to the window menu via the Alt+Space and -Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented -applications. - - -#### Support for applying STARTUPINFO show command {#features_34_win32_showdefault} - -GLFW now provides the [GLFW_WIN32_SHOWDEFAULT](@ref GLFW_WIN32_SHOWDEFAULT_hint) window -hint for applying the show command in the program's `STARTUPINFO` when showing the window -for the first time. This may be useful for the main window of a windowed-mode tool. - - -#### Wayland libdecor decorations {#wayland_libdecor_34} - -GLFW now supports improved fallback window decorations via -[libdecor](https://gitlab.freedesktop.org/libdecor/libdecor). - -Support for libdecor can be toggled before GLFW is initialized with the -[GLFW_WAYLAND_LIBDECOR](@ref GLFW_WAYLAND_LIBDECOR_hint) init hint. It is -enabled by default. - - -#### Window hint for Wayland app_id {#wayland_app_id_34} - -GLFW now supports specifying the app_id for a Wayland window using the -[GLFW_WAYLAND_APP_ID](@ref GLFW_WAYLAND_APP_ID_hint) window hint string. - - -#### Support for ANGLE rendering backend selection {#features_34_angle_backend} - -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/ - - -#### Window hint for hardware acceleration {#acceleration_34} +### Window hint for hardware acceleration {#acceleration} You can use window hint [GLFW_ACCELERATION](@ref GLFW_ACCELERATION_hint) to specify whether hardware acceleration is preferred or not. The default value @@ -151,202 +24,33 @@ is enabled with the window attribute available on WGL currently. -### Caveats for version 3.4 {#caveats} +## Caveats {#caveats} -#### Multiple sets of native access functions {#native_34} - -Because GLFW now supports runtime selection of platform (window system), a library binary -may export native access functions for multiple platforms. Starting with version 3.4 you -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_34} - -Because GLFW now supports runtime selection of platform (window system), the version -string returned by @ref glfwGetVersionString has been expanded. It now contains the names -of all APIs for all the platforms that the library binary supports. - - -#### Joystick support is initialized on demand {#joysticks_34} - -The joystick part of GLFW is now initialized when first used, primarily to work -around faulty Windows drivers that cause DirectInput to take up to several -seconds to enumerate devices. - -This change will usually not be observable. However, if your application waits -for events without having first called any joystick function or created any -visible windows, the wait may never unblock as GLFW may not yet have subscribed -to joystick related OS events. - -To work around this, call any joystick function before waiting for events, for -example by setting a [joystick callback](@ref joystick_event). - - -#### Framebuffer may lack alpha channel on older Wayland systems {#wayland_alpha_34} - -On Wayland, when creating an EGL context on a machine lacking the new -`EGL_EXT_present_opaque` extension, the @ref GLFW_ALPHA_BITS window hint will be -ignored and the framebuffer will have no alpha channel. This is because some -Wayland compositors treat any buffer with an alpha channel as per-pixel -transparent. - -If you want a per-pixel transparent window, see the -[GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) window -hint. - - -#### Tests and examples are disabled when built as a subproject {#standalone_34} - -GLFW now does not build the tests and examples when it is added as -a subdirectory of another CMake project. To enable these, set the @ref -GLFW_BUILD_TESTS and @ref GLFW_BUILD_EXAMPLES cache variables before adding the -GLFW subdirectory. - -```cmake -set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE) -set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE) -add_subdirectory(path/to/glfw) -``` - - -#### macOS main menu now created at initialization {#initmenu_34} - -GLFW now creates the main menu and completes the initialization of NSApplication -during initialization. Programs that do not want a main menu can disable it -with the [GLFW_COCOA_MENUBAR](@ref GLFW_COCOA_MENUBAR_hint) init hint. - - -#### CoreVideo dependency has been removed {#corevideo_34} - -GLFW no longer depends on the CoreVideo framework on macOS and it no longer -needs to be specified during compilation or linking. - - -#### Framebuffer transparency requires DWM transparency {#caveat_fbtransparency_34} - -GLFW no longer supports framebuffer transparency enabled via @ref -GLFW_TRANSPARENT_FRAMEBUFFER on Windows 7 if DWM transparency is off -(the Transparency setting under Personalization > Window Color). - - -#### Empty events on X11 no longer round-trip to server {#emptyevents_34} - -Events posted with @ref glfwPostEmptyEvent now use a separate unnamed pipe -instead of sending an X11 client event to the helper window. - - -#### Microsoft GDI software OpenGL ICD support {#gdi_opengl_icd_34} +### Microsoft GDI software OpenGL ICD support {#gdi_opengl_icd} GLFW now supports creating window when the Microsoft GDI software OpenGL ICD is the only available implementation. See [GLFW_ACCELERATION](@ref GLFW_ACCELERATION_hint) for more details. -### Deprecations in version 3.4 {#deprecations_34} +## Deprecations {#deprecations} -### Removals in 3.4 {#removals_34} +## Removals {#removals} -#### GLFW_VULKAN_STATIC CMake option has been removed {#vulkan_static_34} +## New symbols {#new_symbols} -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. +### New functions {#new_functions} -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. +### New types {#new_types} +### New constants {#new_constants} -#### GLFW_USE_OSMESA CMake option has been removed {#osmesa_option_34} - -This option was used to compile GLFW for the Null platform. The Null platform is now -always supported. To produce a library binary that only supports this platform, the way -this CMake option used to do, you will instead need to disable the default platform for -the target OS. This means setting the @ref GLFW_BUILD_WIN32, @ref GLFW_BUILD_COCOA or -@ref GLFW_BUILD_X11 CMake option to false. - -You can set all of them to false and the ones that don't apply for the target OS will be -ignored. - - -#### Support for the wl_shell protocol has been removed {#wl_shell_34} - -Support for the wl_shell protocol has been removed and GLFW now only supports -the XDG-Shell protocol. If your Wayland compositor does not support XDG-Shell -then GLFW will fail to initialize. - - -### New symbols in version 3.4 {#symbols_34} - -#### New functions in version 3.4 {#functions_34} - - - @ref glfwInitAllocator - - @ref glfwGetPlatform - - @ref glfwPlatformSupported - - @ref glfwInitVulkanLoader - - @ref glfwGetWindowTitle - - @ref glfwGetCocoaView - - -#### New types in version 3.4 {#types_34} - - - @ref GLFWallocator - - @ref GLFWallocatefun - - @ref GLFWreallocatefun - - @ref GLFWdeallocatefun - - -#### New constants in version 3.4 {#constants_34} - - - @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 - - @ref GLFW_ACCELERATION - +- @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) - [Release notes for 3.3](https://www.glfw.org/docs/3.3/news.html) - [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html) - [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html) - [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html) - diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index f1dc891c..2da5ebcb 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 @@ -1157,11 +1157,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 @@ -3187,8 +3188,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 @@ -4681,8 +4682,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: @@ -4722,6 +4723,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 @@ -4916,8 +4922,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 @@ -5293,10 +5302,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/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 92f0d324..011b239c 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -1,5 +1,5 @@ /************************************************************************* - * GLFW 3.4 - www.glfw.org + * GLFW 3.5 - www.glfw.org * A library for OpenGL, window and input *------------------------------------------------------------------------ * Copyright (c) 2002-2006 Marcus Geelnard diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1057a6f9..463b898d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -151,10 +151,11 @@ endif() if (GLFW_BUILD_COCOA) target_link_libraries(glfw PRIVATE "-framework Cocoa" "-framework IOKit" - "-framework CoreFoundation") + "-framework CoreFoundation" + "-framework QuartzCore") set(glfw_PKG_DEPS "") - set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation") + set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation -framework QuartzCore") endif() if (GLFW_BUILD_WAYLAND) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index e75a5519..15dc4ec4 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // diff --git a/src/cocoa_joystick.h b/src/cocoa_joystick.h index 2f46dfcb..c3a58e23 100644 --- a/src/cocoa_joystick.h +++ b/src/cocoa_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Cocoa - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2017 Camilla Löwy // diff --git a/src/cocoa_joystick.m b/src/cocoa_joystick.m index d5de4793..bb86ad22 100644 --- a/src/cocoa_joystick.m +++ b/src/cocoa_joystick.m @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Cocoa - www.glfw.org +// GLFW 3.5 Cocoa - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // Copyright (c) 2012 Torsten Walluhn diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index e351088a..6495e1f3 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 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -136,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)) @@ -163,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) { @@ -179,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; @@ -549,13 +550,20 @@ GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count) } // autoreleasepool } -void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode) +GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode *mode) { @autoreleasepool { CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID); + if (!native) + { + _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to query display mode"); + return GLFW_FALSE; + } + *mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate); CGDisplayModeRelease(native); + return GLFW_TRUE; } // autoreleasepool } @@ -620,7 +628,6 @@ void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) @@ -629,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_platform.h b/src/cocoa_platform.h index 3d424ee7..4d1d66ae 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2019 Camilla Löwy // @@ -281,7 +281,7 @@ void _glfwGetMonitorPosCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleCocoa(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaCocoa(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesCocoa(_GLFWmonitor* monitor, int* count); -void _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeCocoa(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampCocoa(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampCocoa(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); diff --git a/src/cocoa_time.c b/src/cocoa_time.c index d56f145f..a153edb3 100644 --- a/src/cocoa_time.c +++ b/src/cocoa_time.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2016 Camilla Löwy // diff --git a/src/cocoa_time.h b/src/cocoa_time.h index 3512e8b6..8463cbb6 100644 --- a/src/cocoa_time.h +++ b/src/cocoa_time.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 macOS - www.glfw.org +// GLFW 3.5 macOS - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2009-2021 Camilla Löwy // diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 0dcf0a38..e69b5fe0 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 // @@ -28,8 +28,11 @@ #if defined(_GLFW_COCOA) +#import + #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 @@ -309,7 +312,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) @@ -317,7 +319,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; else window->ns.occluded = GLFW_TRUE; } -#endif } @end @@ -1949,19 +1950,8 @@ 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"]; - 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, @@ -2026,9 +2016,6 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, } return err; -#else - return VK_ERROR_EXTENSION_NOT_PRESENT; -#endif } // autoreleasepool } @@ -2040,7 +2027,6 @@ VkResult _glfwCreateWindowSurfaceCocoa(VkInstance instance, GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) @@ -2050,12 +2036,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; _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) @@ -2065,6 +2053,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 fc9e0c96..d1b7af3e 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 @@ -624,11 +624,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) @@ -656,11 +656,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 ef65dd35..517c64cb 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 @@ -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) @@ -883,13 +908,19 @@ GLFWAPI EGLDisplay glfwGetEGLDisplay(void) GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + 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; @@ -897,13 +928,19 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle) GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + 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; diff --git a/src/glx_context.c b/src/glx_context.c index 7082682b..a2464a9d 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 @@ -677,7 +677,6 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig, GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -686,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); @@ -697,7 +699,6 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle) GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -706,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/init.c b/src/init.c index 532264e1..dbd5a900 100644 --- a/src/init.c +++ b/src/init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2018 Camilla Löwy diff --git a/src/input.c b/src/input.c index 7b3b3402..c619eefc 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 @@ -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); @@ -559,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: @@ -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); @@ -584,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: @@ -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); @@ -734,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); @@ -757,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); @@ -780,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) @@ -790,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) @@ -803,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) { @@ -897,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; @@ -932,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); @@ -945,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; } @@ -976,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; } @@ -987,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; } @@ -998,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; } @@ -1009,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/internal.h b/src/internal.h index b4ed0c6f..88975077 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 @@ -48,6 +48,8 @@ #define GLFW_INCLUDE_NONE #include "../include/GLFW/glfw3.h" +#include + #define _GLFW_INSERT_FIRST 0 #define _GLFW_INSERT_LAST 1 @@ -150,6 +152,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 +186,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 +211,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 +228,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 @@ -277,6 +285,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; @@ -546,6 +555,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]; @@ -702,7 +712,7 @@ struct _GLFWplatform void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*); void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*); GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*); - void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*); + GLFWbool (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*); GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*); void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*); // window @@ -813,6 +823,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 +838,7 @@ struct _GLFWlibrary PFN_eglDestroySurface DestroySurface; PFN_eglDestroyContext DestroyContext; PFN_eglCreateWindowSurface CreateWindowSurface; + PFN_eglCreatePbufferSurface CreatePbufferSurface; PFN_eglMakeCurrent MakeCurrent; PFN_eglSwapBuffers SwapBuffers; PFN_eglSwapInterval SwapInterval; @@ -862,6 +874,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/linux_joystick.c b/src/linux_joystick.c index 07d41d37..d8a916b0 100644 --- a/src/linux_joystick.c +++ b/src/linux_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Linux - www.glfw.org +// GLFW 3.5 Linux - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/linux_joystick.h b/src/linux_joystick.h index 64462b04..1ea3deb3 100644 --- a/src/linux_joystick.h +++ b/src/linux_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Linux - www.glfw.org +// GLFW 3.5 Linux - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/src/mappings.h b/src/mappings.h index 270fa4cd..cd32e5d0 100644 --- a/src/mappings.h +++ b/src/mappings.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2018 Camilla Löwy // diff --git a/src/mappings.h.in b/src/mappings.h.in index ed623680..99d18330 100644 --- a/src/mappings.h.in +++ b/src/mappings.h.in @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2018 Camilla Löwy // diff --git a/src/monitor.c b/src/monitor.c index b76ac6db..cc95efb6 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 @@ -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,12 +450,14 @@ 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; - _glfw.platform.getVideoMode(monitor, &monitor->currentMode); return &monitor->currentMode; } @@ -460,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); @@ -503,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; @@ -517,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); @@ -527,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 daa8367a..df729800 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 // @@ -30,6 +30,7 @@ #include #include +#include static void makeContextCurrentNSGL(_GLFWwindow* window) { @@ -182,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) \ @@ -217,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); } @@ -361,7 +359,6 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(nil); if (_glfw.platform.platformID != GLFW_PLATFORM_COCOA) @@ -371,6 +368,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/null_init.c b/src/null_init.c index 88940fcd..8c10f5e6 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016 Google Inc. // Copyright (c) 2016-2017 Camilla Löwy diff --git a/src/null_joystick.c b/src/null_joystick.c index ec1f6b55..16dc8cf3 100644 --- a/src/null_joystick.c +++ b/src/null_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016-2017 Camilla Löwy // diff --git a/src/null_joystick.h b/src/null_joystick.h index a2199c56..40a490f9 100644 --- a/src/null_joystick.h +++ b/src/null_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2017 Camilla Löwy // diff --git a/src/null_monitor.c b/src/null_monitor.c index 63cd462f..a9b528f0 100644 --- a/src/null_monitor.c +++ b/src/null_monitor.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2016 Google Inc. // Copyright (c) 2016-2019 Camilla Löwy @@ -109,9 +109,10 @@ GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found) return mode; } -void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode) +GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode) { *mode = getVideoMode(); + return GLFW_TRUE; } GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp) diff --git a/src/null_platform.h b/src/null_platform.h index f9706acc..dbcb835b 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 @@ -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 @@ -204,7 +215,7 @@ void _glfwGetMonitorPosNull(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleNull(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaNull(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesNull(_GLFWmonitor* monitor, int* found); -void _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeNull(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampNull(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampNull(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); diff --git a/src/null_window.c b/src/null_window.c index 1db08114..f0e1dcc9 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 @@ -28,6 +28,7 @@ #include "internal.h" #include +#include static void applySizeLimits(_GLFWwindow* window, int* width, int* height) { @@ -552,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) @@ -699,13 +703,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 +722,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/osmesa_context.c b/src/osmesa_context.c index 2f12adf2..0bb375a8 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 @@ -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,9 +371,11 @@ GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle, GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + if (window->context.source != GLFW_OSMESA_CONTEXT_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); diff --git a/src/platform.c b/src/platform.c index af1b0f44..9ca64963 100644 --- a/src/platform.c +++ b/src/platform.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2018 Camilla Löwy diff --git a/src/platform.h b/src/platform.h index 75652dcc..7ce4e015 100644 --- a/src/platform.h +++ b/src/platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 - www.glfw.org +// GLFW 3.5 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2018 Camilla Löwy diff --git a/src/posix_module.c b/src/posix_module.c index 7d81c672..b3482d26 100644 --- a/src/posix_module.c +++ b/src/posix_module.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2021 Camilla Löwy // diff --git a/src/posix_poll.c b/src/posix_poll.c index b53e36e8..595cf717 100644 --- a/src/posix_poll.c +++ b/src/posix_poll.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2022 Camilla Löwy // diff --git a/src/posix_poll.h b/src/posix_poll.h index 4bdd2448..a0ef3962 100644 --- a/src/posix_poll.h +++ b/src/posix_poll.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2022 Camilla Löwy // diff --git a/src/posix_thread.c b/src/posix_thread.c index 3c355a53..bab74d4f 100644 --- a/src/posix_thread.c +++ b/src/posix_thread.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/posix_thread.h b/src/posix_thread.h index 5a5d7b7c..ce298a8b 100644 --- a/src/posix_thread.h +++ b/src/posix_thread.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/posix_time.c b/src/posix_time.c index a1724084..4d7bd7ce 100644 --- a/src/posix_time.c +++ b/src/posix_time.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/posix_time.h b/src/posix_time.h index 94374adb..39faa0fc 100644 --- a/src/posix_time.h +++ b/src/posix_time.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 POSIX - www.glfw.org +// GLFW 3.5 POSIX - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/vulkan.c b/src/vulkan.c index d9fabdea..9c87fcfe 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 @@ -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); @@ -272,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; @@ -297,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 a7e9cbf0..8f0b1da8 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 @@ -776,7 +776,6 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window, GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) @@ -786,6 +785,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_init.c b/src/win32_init.c index 824e383c..77ab56ba 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 59389a90..6703485e 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/win32_joystick.h b/src/win32_joystick.h index 9ab6438b..2d8f59d0 100644 --- a/src/win32_joystick.h +++ b/src/win32_joystick.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2006-2017 Camilla Löwy // diff --git a/src/win32_module.c b/src/win32_module.c index 47c8dff6..b76599b6 100644 --- a/src/win32_module.c +++ b/src/win32_module.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2021 Camilla Löwy // diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 4edaf2c3..87e5c206 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 @@ -33,6 +33,7 @@ #include #include #include +#include // Callback for EnumDisplayMonitors in createMonitor @@ -470,13 +471,17 @@ GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count) return result; } -void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode) +GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode) { DEVMODEW dm; ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); - EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm); + if (!EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm)) + { + _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to query display settings"); + return GLFW_FALSE; + } mode->width = dm.dmPelsWidth; mode->height = dm.dmPelsHeight; @@ -485,6 +490,8 @@ void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode) &mode->redBits, &mode->greenBits, &mode->blueBits); + + return GLFW_TRUE; } GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp) @@ -533,7 +540,6 @@ void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) @@ -542,12 +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; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) @@ -556,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_platform.h b/src/win32_platform.h index a5bfa586..af7701e3 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 @@ -611,7 +611,7 @@ void _glfwGetMonitorPosWin32(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleWin32(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaWin32(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesWin32(_GLFWmonitor* monitor, int* count); -void _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeWin32(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampWin32(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampWin32(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); diff --git a/src/win32_thread.c b/src/win32_thread.c index 212e666c..6e418d7a 100644 --- a/src/win32_thread.c +++ b/src/win32_thread.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/win32_thread.h b/src/win32_thread.h index dd5948f0..ca96fae2 100644 --- a/src/win32_thread.h +++ b/src/win32_thread.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/win32_time.c b/src/win32_time.c index a38e15dd..4a4b2cbb 100644 --- a/src/win32_time.c +++ b/src/win32_time.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/win32_time.h b/src/win32_time.h index ef57a5a6..f72a5d04 100644 --- a/src/win32_time.h +++ b/src/win32_time.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Win32 - www.glfw.org +// GLFW 3.5 Win32 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/win32_window.c b/src/win32_window.c index e6a9496c..d014944b 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 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -2576,7 +2577,6 @@ VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance, GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32) @@ -2586,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 31753297..7a5a1506 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 @@ -472,10 +472,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; @@ -506,40 +506,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); @@ -551,14 +554,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"); @@ -582,25 +586,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; @@ -609,27 +614,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; @@ -640,11 +647,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) @@ -683,13 +690,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) @@ -712,15 +720,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); } @@ -728,9 +737,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) @@ -741,43 +747,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); @@ -789,29 +802,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; @@ -820,11 +835,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; @@ -836,21 +851,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; @@ -859,21 +874,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: @@ -934,11 +949,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) @@ -980,10 +995,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; } @@ -993,14 +1009,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, @@ -1028,29 +1045,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; } @@ -1058,10 +1078,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; } @@ -1069,10 +1090,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; } @@ -1080,10 +1102,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; } @@ -1091,10 +1114,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; } @@ -1102,10 +1126,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; } @@ -1113,10 +1138,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; } @@ -1124,10 +1150,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; } @@ -1135,10 +1162,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_init.c b/src/wl_init.c index 3aff476d..76054bc6 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 // @@ -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, diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 66639301..1ec5f5af 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 // @@ -33,6 +33,7 @@ #include #include #include +#include #include "wayland-client-protocol.h" @@ -232,9 +233,10 @@ GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* found) return monitor->modes; } -void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode) +GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode) { *mode = monitor->modes[monitor->wl.currentMode]; + return GLFW_TRUE; } GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp) @@ -257,7 +259,6 @@ void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) @@ -266,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_platform.h b/src/wl_platform.h index b3478df1..f3e8cba2 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 // @@ -28,8 +28,6 @@ #include #include -#include - typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; typedef struct VkWaylandSurfaceCreateInfoKHR @@ -679,7 +677,7 @@ void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count); -void _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); diff --git a/src/wl_window.c b/src/wl_window.c index 5b491ffb..2e842aaa 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 // @@ -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 (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, @@ -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, @@ -2183,6 +2185,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); @@ -3291,7 +3299,6 @@ GLFWAPI struct wl_display* glfwGetWaylandDisplay(void) GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (_glfw.platform.platformID != GLFW_PLATFORM_WAYLAND) @@ -3301,6 +3308,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_init.c b/src/x11_init.c index e992f444..982c526c 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 X11 - www.glfw.org +// GLFW 3.5 X11 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 31640fb1..3af82752 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 @@ -33,6 +33,7 @@ #include #include #include +#include // Check whether the display mode should be included in enumeration @@ -491,24 +492,31 @@ GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count) return result; } -void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode) +GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode) { if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) { XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); - XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); + const XRRModeInfo* mi = NULL; + XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); if (ci) { - const XRRModeInfo* mi = getModeInfo(sr, ci->mode); - if (mi) // mi can be NULL if the monitor has been disconnected + mi = getModeInfo(sr, ci->mode); + if (mi) *mode = vidmodeFromModeInfo(mi, ci); XRRFreeCrtcInfo(ci); } XRRFreeScreenResources(sr); + + if (!mi) + { + _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to query video mode"); + return GLFW_FALSE; + } } else { @@ -519,6 +527,8 @@ void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode) _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen), &mode->redBits, &mode->greenBits, &mode->blueBits); } + + return GLFW_TRUE; } GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp) @@ -602,7 +612,6 @@ void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle) { - _GLFWmonitor* monitor = (_GLFWmonitor*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -611,12 +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; _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -625,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_platform.h b/src/x11_platform.h index cdea3957..30326c5b 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 X11 - www.glfw.org +// GLFW 3.5 X11 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2019 Camilla Löwy @@ -968,7 +968,7 @@ void _glfwGetMonitorPosX11(_GLFWmonitor* monitor, int* xpos, int* ypos); void _glfwGetMonitorContentScaleX11(_GLFWmonitor* monitor, float* xscale, float* yscale); void _glfwGetMonitorWorkareaX11(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); GLFWvidmode* _glfwGetVideoModesX11(_GLFWmonitor* monitor, int* count); -void _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWbool _glfwGetVideoModeX11(_GLFWmonitor* monitor, GLFWvidmode* mode); GLFWbool _glfwGetGammaRampX11(_GLFWmonitor* monitor, GLFWgammaramp* ramp); void _glfwSetGammaRampX11(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); diff --git a/src/x11_window.c b/src/x11_window.c index e0295465..322349f0 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 @@ -3302,7 +3302,6 @@ GLFWAPI Display* glfwGetX11Display(void) GLFWAPI Window glfwGetX11Window(GLFWwindow* handle) { - _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(None); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) @@ -3311,11 +3310,16 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* handle) return None; } + _GLFWwindow* window = (_GLFWwindow*) handle; + assert(window != NULL); + return window->x11.handle; } GLFWAPI void glfwSetX11SelectionString(const char* string) { + assert(string != NULL); + _GLFW_REQUIRE_INIT(); if (_glfw.platform.platformID != GLFW_PLATFORM_X11) diff --git a/src/xkb_unicode.c b/src/xkb_unicode.c index 6b8dfcac..68767cc3 100644 --- a/src/xkb_unicode.c +++ b/src/xkb_unicode.c @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 X11 - www.glfw.org +// GLFW 3.5 X11 - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2006-2017 Camilla Löwy diff --git a/src/xkb_unicode.h b/src/xkb_unicode.h index b07408f6..d52748ac 100644 --- a/src/xkb_unicode.h +++ b/src/xkb_unicode.h @@ -1,5 +1,5 @@ //======================================================================== -// GLFW 3.4 Linux - www.glfw.org +// GLFW 3.5 Linux - www.glfw.org //------------------------------------------------------------------------ // Copyright (c) 2014 Jonas Ådahl // diff --git a/tests/events.c b/tests/events.c index fdc3c199..ab3b99a7 100644 --- a/tests/events.c +++ b/tests/events.c @@ -630,6 +630,7 @@ int main(int argc, char** argv) glfwTerminate(); exit(EXIT_FAILURE); } + glfwSetInputMode(slots[i].window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE); glfwSetWindowUserPointer(slots[i].window, slots + i); diff --git a/tests/window.c b/tests/window.c index c81bf024..ffea5dbf 100644 --- a/tests/window.c +++ b/tests/window.c @@ -78,6 +78,7 @@ int main(int argc, char** argv) glfwTerminate(); exit(EXIT_FAILURE); } + glfwSetInputMode(window, GLFW_UNLIMITED_MOUSE_BUTTONS, GLFW_TRUE); glfwMakeContextCurrent(window); gladLoadGL(glfwGetProcAddress);