Merge branch '3.3-stable' into new-cursors-on-3.3-stable

This commit is contained in:
Camilla Löwy 2021-10-14 00:17:57 +02:00
commit cc5f563905
15 changed files with 712 additions and 161 deletions

View File

@ -23,18 +23,18 @@ endif()
file(STRINGS "${source_path}" lines)
foreach(line ${lines})
if ("${line}" MATCHES "^[0-9a-fA-F].*$")
if ("${line}" MATCHES "platform:Windows")
if (line MATCHES "^[0-9a-fA-F]")
if (line MATCHES "platform:Windows")
if (GLFW_WIN32_MAPPINGS)
set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\n")
endif()
set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\"${line}\",")
elseif ("${line}" MATCHES "platform:Mac OS X")
elseif (line MATCHES "platform:Mac OS X")
if (GLFW_COCOA_MAPPINGS)
set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\n")
endif()
set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\"${line}\",")
elseif ("${line}" MATCHES "platform:Linux")
elseif (line MATCHES "platform:Linux")
if (GLFW_LINUX_MAPPINGS)
set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\n")
endif()

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.0...3.20 FATAL_ERROR)
project(GLFW VERSION 3.3.5 LANGUAGES C)
@ -67,7 +67,8 @@ if (GLFW_BUILD_DOCS)
endif()
#--------------------------------------------------------------------
# Set compiler specific flags
# Apply Microsoft C runtime library option
# This is here because it also applies to tests and examples
#--------------------------------------------------------------------
if (MSVC)
if (MSVC90)
@ -83,17 +84,17 @@ if (MSVC)
endif()
if (MSVC AND NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
if (${CMAKE_VERSION} VERSION_LESS 3.15)
if (CMAKE_VERSION VERSION_LESS 3.15)
foreach (flag CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO)
if (${flag} MATCHES "/MD")
if (flag MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
if (${flag} MATCHES "/MDd")
if (flag MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
endif()
@ -268,7 +269,7 @@ if (_GLFW_WAYLAND)
check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H)
check_function_exists(memfd_create HAVE_MEMFD_CREATE)
if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(EpollShim)
if (EPOLLSHIM_FOUND)
list(APPEND glfw_INCLUDE_DIRS "${EPOLLSHIM_INCLUDE_DIRS}")

View File

@ -126,6 +126,11 @@ information on what to include when reporting a bug.
- [Win32] Bugfix: Compilation with LLVM for Windows failed (#1807,#1824,#1874)
- [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)
- [X11] Bugfix: Changing `GLFW_FLOATING` could leak memory
- [Wayland] Bugfix: Some keys were not repeating in Wayland (#1908)
- [Wayland] Bugfix: Non-arrow cursors are offset from the hotspot (#1706,#1899)
- [NSGL] Bugfix: Defining `GL_SILENCE_DEPRECATION` externally caused
a duplicate definition warning (#1840)
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843)
@ -168,6 +173,7 @@ skills.
- Denis Bernard
- Doug Binks
- blanco
- Waris Boonyasiriwat
- Kyle Brenneman
- Rok Breulj
- Kai Burjack
@ -176,6 +182,7 @@ skills.
- David Carlier
- Arturo Castro
- Chi-kwan Chan
- Joseph Chua
- Ian Clarkson
- Michał Cichoń
- Lambert Clara
@ -227,6 +234,7 @@ skills.
- Arseny Kapoulkine
- Cem Karan
- Osman Keskin
- Koray Kilinc
- Josh Kilmer
- Byunghoon Kim
- Cameron King
@ -346,7 +354,6 @@ skills.
- Torsten Walluhn
- Patrick Walton
- Xo Wang
- Waris
- Jay Weisskopf
- Frank Wille
- Richard A. Wilkes

View File

@ -1293,7 +1293,7 @@ typedef struct GLFWcursor GLFWcursor;
*
* @ingroup init
*/
typedef void (* GLFWerrorfun)(int,const char*);
typedef void (* GLFWerrorfun)(int error_code, const char* description);
/*! @brief The function pointer type for window position callbacks.
*
@ -1316,7 +1316,7 @@ typedef void (* GLFWerrorfun)(int,const char*);
*
* @ingroup window
*/
typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
typedef void (* GLFWwindowposfun)(GLFWwindow* window, int xpos, int ypos);
/*! @brief The function pointer type for window size callbacks.
*
@ -1338,7 +1338,7 @@ typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
*
* @ingroup window
*/
typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
typedef void (* GLFWwindowsizefun)(GLFWwindow* window, int width, int height);
/*! @brief The function pointer type for window close callbacks.
*
@ -1358,7 +1358,7 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
*
* @ingroup window
*/
typedef void (* GLFWwindowclosefun)(GLFWwindow*);
typedef void (* GLFWwindowclosefun)(GLFWwindow* window);
/*! @brief The function pointer type for window content refresh callbacks.
*
@ -1378,7 +1378,7 @@ typedef void (* GLFWwindowclosefun)(GLFWwindow*);
*
* @ingroup window
*/
typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
typedef void (* GLFWwindowrefreshfun)(GLFWwindow* window);
/*! @brief The function pointer type for window focus callbacks.
*
@ -1399,7 +1399,7 @@ typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
*
* @ingroup window
*/
typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
typedef void (* GLFWwindowfocusfun)(GLFWwindow* window, int focused);
/*! @brief The function pointer type for window iconify callbacks.
*
@ -1420,7 +1420,7 @@ typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
*
* @ingroup window
*/
typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
typedef void (* GLFWwindowiconifyfun)(GLFWwindow* window, int iconified);
/*! @brief The function pointer type for window maximize callbacks.
*
@ -1441,7 +1441,7 @@ typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
*
* @ingroup window
*/
typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
typedef void (* GLFWwindowmaximizefun)(GLFWwindow* window, int maximized);
/*! @brief The function pointer type for framebuffer size callbacks.
*
@ -1462,7 +1462,7 @@ typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
*
* @ingroup window
*/
typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
typedef void (* GLFWframebuffersizefun)(GLFWwindow* window, int width, int height);
/*! @brief The function pointer type for window content scale callbacks.
*
@ -1483,7 +1483,7 @@ typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
*
* @ingroup window
*/
typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, float yscale);
/*! @brief The function pointer type for mouse button callbacks.
*
@ -1509,7 +1509,7 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
*
* @ingroup input
*/
typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods);
/*! @brief The function pointer type for cursor position callbacks.
*
@ -1532,7 +1532,7 @@ typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
*
* @ingroup input
*/
typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
typedef void (* GLFWcursorposfun)(GLFWwindow* window, double xpos, double ypos);
/*! @brief The function pointer type for cursor enter/leave callbacks.
*
@ -1553,7 +1553,7 @@ typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
*
* @ingroup input
*/
typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
typedef void (* GLFWcursorenterfun)(GLFWwindow* window, int entered);
/*! @brief The function pointer type for scroll callbacks.
*
@ -1574,7 +1574,7 @@ typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
*
* @ingroup input
*/
typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
typedef void (* GLFWscrollfun)(GLFWwindow* window, double xoffset, double yoffset);
/*! @brief The function pointer type for keyboard key callbacks.
*
@ -1600,7 +1600,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
*
* @ingroup input
*/
typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
typedef void (* GLFWkeyfun)(GLFWwindow* window, int key, int scancode, int action, int mods);
/*! @brief The function pointer type for Unicode character callbacks.
*
@ -1621,7 +1621,7 @@ typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
*
* @ingroup input
*/
typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint);
/*! @brief The function pointer type for Unicode character with modifiers
* callbacks.
@ -1648,7 +1648,7 @@ typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
*
* @ingroup input
*/
typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods);
/*! @brief The function pointer type for path drop callbacks.
*
@ -1672,7 +1672,7 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
*
* @ingroup input
*/
typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]);
typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]);
/*! @brief The function pointer type for monitor configuration callbacks.
*
@ -1693,7 +1693,7 @@ typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]);
*
* @ingroup monitor
*/
typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
typedef void (* GLFWmonitorfun)(GLFWmonitor* monitor, int event);
/*! @brief The function pointer type for joystick configuration callbacks.
*
@ -1714,7 +1714,7 @@ typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
*
* @ingroup input
*/
typedef void (* GLFWjoystickfun)(int,int);
typedef void (* GLFWjoystickfun)(int jid, int event);
/*! @brief Video mode type.
*
@ -2202,8 +2202,8 @@ GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos,
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
*
* @remark @win32 calculates the returned physical size from the
* current resolution and system DPI instead of querying the monitor EDID data.
* @remark @win32 On Windows 8 and earlier the physical size is calculated from
* the current resolution and system DPI instead of querying the monitor EDID data.
*
* @thread_safety This function must only be called from the main thread.
*
@ -5760,13 +5760,11 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
* This function returns whether the Vulkan loader and any minimally functional
* ICD have been found.
*
* The availability of a Vulkan loader and even an ICD does not by itself
* guarantee that surface creation or even instance creation is possible.
* For example, on Fermi systems Nvidia will install an ICD that provides no
* actual Vulkan support. Call @ref glfwGetRequiredInstanceExtensions to check
* whether the extensions necessary for Vulkan surface creation are available
* and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
* family of a physical device supports image presentation.
* The availability of a Vulkan loader and even an ICD does not by itself guarantee that
* surface creation or even instance creation is possible. Call @ref
* glfwGetRequiredInstanceExtensions to check whether the extensions necessary for Vulkan
* surface creation are available and @ref glfwGetPhysicalDevicePresentationSupport to
* check whether a queue family of a physical device supports image presentation.
*
* @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
* otherwise.

View File

@ -114,10 +114,11 @@ static void updateCursorMode(_GLFWwindow* window)
else if (_glfw.ns.disabledCursorWindow == window)
{
_glfw.ns.disabledCursorWindow = NULL;
CGAssociateMouseAndMouseCursorPosition(true);
_glfwPlatformSetCursorPos(window,
_glfw.ns.restoreCursorPosX,
_glfw.ns.restoreCursorPosY);
// NOTE: The matching CGAssociateMouseAndMouseCursorPosition call is
// made in _glfwPlatformSetCursorPos as part of a workaround
}
if (cursorInContentArea(window))
@ -1523,6 +1524,11 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
_glfwTransformYNS(globalPoint.y)));
}
// HACK: Calling this right after setting the cursor position prevents macOS
// from freezing the cursor for a fraction of a second afterwards
if (window->cursorMode != GLFW_CURSOR_DISABLED)
CGAssociateMouseAndMouseCursorPosition(true);
} // autoreleasepool
}

View File

@ -28,7 +28,6 @@
//========================================================================
#include "internal.h"
#include "mappings.h"
#include <string.h>
#include <stdlib.h>
@ -247,24 +246,12 @@ GLFWAPI int glfwInit(void)
_glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
_glfwInitGamepadMappings();
_glfw.initialized = GLFW_TRUE;
_glfw.timer.offset = _glfwPlatformGetTimerValue();
glfwDefaultWindowHints();
{
int i;
for (i = 0; _glfwDefaultMappings[i]; i++)
{
if (!glfwUpdateGamepadMappings(_glfwDefaultMappings[i]))
{
terminate();
return GLFW_FALSE;
}
}
}
return GLFW_TRUE;
}

View File

@ -28,6 +28,7 @@
//========================================================================
#include "internal.h"
#include "mappings.h"
#include <assert.h>
#include <float.h>
@ -396,6 +397,21 @@ void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Adds the built-in set of gamepad mappings
//
void _glfwInitGamepadMappings(void)
{
size_t i;
const size_t count = sizeof(_glfwDefaultMappings) / sizeof(char*);
_glfw.mappings = calloc(count, sizeof(_GLFWmapping));
for (i = 0; i < count; i++)
{
if (parseMapping(&_glfw.mappings[_glfw.mappingCount], _glfwDefaultMappings[i]))
_glfw.mappingCount++;
}
}
// Returns an available joystick object with arrays and name allocated
//
_GLFWjoystick* _glfwAllocJoystick(const char* name,

View File

@ -761,6 +761,7 @@ void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
void _glfwInitGamepadMappings(void);
_GLFWjoystick* _glfwAllocJoystick(const char* name,
const char* guid,
int axisCount,

File diff suppressed because it is too large Load Diff

View File

@ -78,7 +78,5 @@ const char* _glfwDefaultMappings[] =
#if defined(GLFW_BUILD_LINUX_MAPPINGS)
@GLFW_LINUX_MAPPINGS@
#endif // GLFW_BUILD_LINUX_MAPPINGS
NULL
};

View File

@ -40,7 +40,7 @@ static const GUID _glfw_GUID_DEVINTERFACE_HID =
#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
#if defined(_GLFW_BUILD_DLL)
#warning "These symbols must be exported by the executable and have no effect in a DLL"
#pragma message("These symbols must be exported by the executable and have no effect in a DLL")
#endif
// Executables (but not DLLs) exporting this symbol with this value will be

View File

@ -104,6 +104,7 @@ static void pointerHandleEnter(void* data,
window->wl.decorations.focus = focus;
_glfw.wl.serial = serial;
_glfw.wl.pointerEnterSerial = serial;
_glfw.wl.pointerFocus = window;
window->wl.hovered = GLFW_TRUE;
@ -163,7 +164,7 @@ static void setCursor(_GLFWwindow* window, const char* name)
buffer = wl_cursor_image_get_buffer(image);
if (!buffer)
return;
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
surface,
image->hotspot_x / scale,
image->hotspot_y / scale);
@ -560,7 +561,7 @@ static GLFWbool inputChar(_GLFWwindow* window, uint32_t key)
}
}
return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, syms[0]);
return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, code);
}
static void keyboardHandleKey(void* data,

View File

@ -252,6 +252,7 @@ typedef struct _GLFWlibraryWayland
const char* cursorPreviousName;
int cursorTimerfd;
uint32_t serial;
uint32_t pointerEnterSerial;
int32_t keyboardRepeatRate;
int32_t keyboardRepeatDelay;

View File

@ -796,7 +796,7 @@ static void setCursorImage(_GLFWwindow* window,
cursorWayland->yhot = image->hotspot_y;
}
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
surface,
cursorWayland->xhot / scale,
cursorWayland->yhot / scale);
@ -1578,7 +1578,7 @@ static void lockPointer(_GLFWwindow* window)
window->wl.pointerLock.relativePointer = relativePointer;
window->wl.pointerLock.lockedPointer = lockedPointer;
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
NULL, 0, 0);
}
@ -1642,7 +1642,7 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
}
else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
{
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, NULL, 0, 0);
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, NULL, 0, 0);
}
}

View File

@ -2686,14 +2686,14 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
break;
}
if (i < count)
return;
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
PropModeAppend,
(unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
1);
if (i == count)
{
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
PropModeAppend,
(unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
1);
}
}
else if (states)
{
@ -2703,15 +2703,15 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
break;
}
if (i == count)
return;
if (i < count)
{
states[i] = states[count - 1];
count--;
states[i] = states[count - 1];
count--;
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
PropModeReplace, (unsigned char*) states, count);
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.NET_WM_STATE, XA_ATOM, 32,
PropModeReplace, (unsigned char*) states, count);
}
}
if (states)