Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.3/glfw: Update to v3.3.10 for various bug fixes #396

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion v3.3/glfw/GLFW_C_REVISION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e2c92645460f680fd272fd2eed591efb2be7dc31
dc46d3f8129712e42856c20e99a604a3b08ad581
12 changes: 8 additions & 4 deletions v3.3/glfw/glfw/include/GLFW/glfw3.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ extern "C" {
* release is made that does not contain any API changes.
* @ingroup init
*/
#define GLFW_VERSION_REVISION 9
#define GLFW_VERSION_REVISION 10
/*! @} */

/*! @brief One.
Expand Down Expand Up @@ -2611,8 +2611,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
* GLFW_PLATFORM_ERROR.
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
*
* @remark @win32 Window creation will fail if the Microsoft GDI software
* OpenGL implementation is the only one available.
Expand Down Expand Up @@ -3561,11 +3561,15 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
* @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR.
*
* @remark Calling @ref glfwGetWindowAttrib will always return the latest
* value, even if that value is ignored by the current mode of the window.
*
* @remark @wayland The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window
* attribute is not supported. Setting this will emit @ref
* GLFW_PLATFORM_ERROR.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_attribs
Expand Down
5 changes: 3 additions & 2 deletions v3.3/glfw/glfw/src/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -1635,14 +1635,15 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
{
@autoreleasepool {

if (scancode < 0 || scancode > 0xff ||
_glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
if (scancode < 0 || scancode > 0xff)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}

const int key = _glfw.ns.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;

UInt32 deadKeyState = 0;
UniChar characters[4];
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode)

GLFWAPI int glfwGetKeyScancode(int key)
{
_GLFW_REQUIRE_INIT_OR_RETURN(-1);
_GLFW_REQUIRE_INIT_OR_RETURN(0);

if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
{
Expand Down
2 changes: 0 additions & 2 deletions v3.3/glfw/glfw/src/linux_joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,6 @@ void _glfwTerminateJoysticksLinux(void)
closeJoystick(js);
}

regfree(&_glfw.linjs.regex);

if (_glfw.linjs.inotify > 0)
{
if (_glfw.linjs.watch > 0)
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/nsgl_context.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"NSGL: OpenGL ES is not available on macOS");
"NSGL: OpenGL ES is not available via NSGL");
return GLFW_FALSE;
}

Expand Down
5 changes: 2 additions & 3 deletions v3.3/glfw/glfw/src/osmesa_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================

#include "internal.h"

#include <stdlib.h>
#include <string.h>
#include <assert.h>

#include "internal.h"


static void makeContextCurrentOSMesa(_GLFWwindow* window)
{
if (window)
Expand Down
8 changes: 8 additions & 0 deletions v3.3/glfw/glfw/src/wayland-xdg-shell-client-protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ extern const struct wl_interface xdg_surface_interface;
* id, and well as trigger user interactive operations such as interactive
* resize and move.
*
* A xdg_toplevel by default is responsible for providing the full intended
* visual representation of the toplevel, which depending on the window
* state, may mean things like a title bar, window controls and drop shadow.
*
* Unmapping an xdg_toplevel means that the surface cannot be shown
* by the compositor until it is explicitly mapped again.
* All active operations (e.g., move, resize) are canceled and all
Expand All @@ -280,6 +284,10 @@ extern const struct wl_interface xdg_surface_interface;
* id, and well as trigger user interactive operations such as interactive
* resize and move.
*
* A xdg_toplevel by default is responsible for providing the full intended
* visual representation of the toplevel, which depending on the window
* state, may mean things like a title bar, window controls and drop shadow.
*
* Unmapping an xdg_toplevel means that the surface cannot be shown
* by the compositor until it is explicitly mapped again.
* All active operations (e.g., move, resize) are canceled and all
Expand Down
17 changes: 17 additions & 0 deletions v3.3/glfw/glfw/src/wgl_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ static int choosePixelFormat(_GLFWwindow* window,

if (_glfw.wgl.ARB_pixel_format)
{
// NOTE: In a Parallels VM WGL_ARB_pixel_format returns fewer pixel formats than
// DescribePixelFormat, violating the guarantees of the extension spec
// HACK: Iterate through the minimum of both counts

const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
int extensionCount;

if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
1, 0, 1, &attrib, &extensionCount))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to retrieve pixel format attribute");
return 0;
}

nativeCount = _glfw_min(nativeCount, extensionCount);

addAttrib(WGL_SUPPORT_OPENGL_ARB);
addAttrib(WGL_DRAW_TO_WINDOW_ARB);
addAttrib(WGL_PIXEL_TYPE_ARB);
Expand Down
11 changes: 8 additions & 3 deletions v3.3/glfw/glfw/src/win32_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2191,14 +2191,19 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)

const char* _glfwPlatformGetScancodeName(int scancode)
{
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
_glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
int key;

if (scancode < 0 || scancode > (KF_EXTENDED | 0xff))
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}

return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]];
key = _glfw.win32.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;

return _glfw.win32.keynames[key];
}

int _glfwPlatformGetKeyScancode(int key)
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw/src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);

_GLFW_REQUIRE_INIT_OR_RETURN(1.f);
_GLFW_REQUIRE_INIT_OR_RETURN(0.f);
return _glfwPlatformGetWindowOpacity(window);
}

Expand Down
9 changes: 7 additions & 2 deletions v3.3/glfw/glfw/src/wl_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,15 @@ void _glfwPlatformTerminate(void)
_glfwTerminateEGL();
_glfwTerminateOSMesa();

if (_glfw.wl.libdecor.callback)
wl_callback_destroy(_glfw.wl.libdecor.callback);
if (_glfw.wl.libdecor.context)
{
// Allow libdecor to finish receiving all its requested globals
// and ensure the associated sync callback object is destroyed
while (!_glfw.wl.libdecor.ready)
_glfwPlatformWaitEvents();

libdecor_unref(_glfw.wl.libdecor.context);
}

if (_glfw.wl.libdecor.handle)
{
Expand Down
23 changes: 8 additions & 15 deletions v3.3/glfw/glfw/src/wl_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <poll.h>
#include <signal.h>
#include <time.h>
#include <linux/input-event-codes.h>

#define GLFW_BORDER_SIZE 4
#define GLFW_CAPTION_HEIGHT 24
Expand Down Expand Up @@ -1537,24 +1538,14 @@ static void pointerHandleAxis(void* userData,
wl_fixed_t value)
{
_GLFWwindow* window = _glfw.wl.pointerFocus;
double x = 0.0, y = 0.0;
// Wayland scroll events are in pointer motion coordinate space (think two
// finger scroll). The factor 10 is commonly used to convert to "scroll
// step means 1.0.
const double scrollFactor = 1.0 / 10.0;

if (!window)
return;

assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
axis == WL_POINTER_AXIS_VERTICAL_SCROLL);

// NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
x = -wl_fixed_to_double(value) * scrollFactor;
_glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
y = -wl_fixed_to_double(value) * scrollFactor;

_glfwInputScroll(window, x, y);
_glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0);
}

static const struct wl_pointer_listener pointerListener =
Expand Down Expand Up @@ -2585,8 +2576,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)

const char* _glfwPlatformGetScancodeName(int scancode)
{
if (scancode < 0 || scancode > 255 ||
_glfw.wl.keycodes[scancode] == GLFW_KEY_UNKNOWN)
if (scancode < 0 || scancode > 255)
{
_glfwInputError(GLFW_INVALID_VALUE,
"Wayland: Invalid scancode %i",
Expand All @@ -2595,6 +2585,9 @@ const char* _glfwPlatformGetScancodeName(int scancode)
}

const int key = _glfw.wl.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;

const xkb_keycode_t keycode = scancode + 8;
const xkb_layout_index_t layout =
xkb_state_key_get_layout(_glfw.wl.xkb.state, keycode);
Expand Down
6 changes: 4 additions & 2 deletions v3.3/glfw/glfw/src/x11_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2930,14 +2930,16 @@ const char* _glfwPlatformGetScancodeName(int scancode)
if (!_glfw.x11.xkb.available)
return NULL;

if (scancode < 0 || scancode > 0xff ||
_glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
if (scancode < 0 || scancode > 0xff)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}

const int key = _glfw.x11.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;

const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
scancode, _glfw.x11.xkb.group, 0);
if (keysym == NoSymbol)
Expand Down
2 changes: 1 addition & 1 deletion v3.3/glfw/glfw_tree_rebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ package glfw
// generate` on this package. This exists to invalidate the build cache (see
// https://github.com/go-gl/glfw/issues/269), which is unaffected by C source
// inputs.
const upstreamTreeSHA = "2debdd777d6f11e00b7435e91691892d147a777b"
const upstreamTreeSHA = "a4a3bc8c0f4e37695a4de3f51cd7123bc186043b"