diff --git a/internal/glfw/cocoa_window_darwin.m b/internal/glfw/cocoa_window_darwin.m index 1b1a7ebf1..104817978 100644 --- a/internal/glfw/cocoa_window_darwin.m +++ b/internal/glfw/cocoa_window_darwin.m @@ -1621,14 +1621,15 @@ const char* _glfwPlatformGetScancodeName(int scancode) { @autoreleasepool { - if (scancode < 0 || scancode > 0xff || - _glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN) + if (scancode < 0 || scancode > 0xff) { _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode); return NULL; } const int key = _glfw.ns.keycodes[scancode]; + if (key == GLFW_KEY_UNKNOWN) + return NULL; UInt32 deadKeyState = 0; UniChar characters[4]; diff --git a/internal/glfw/glfw3_unix.h b/internal/glfw/glfw3_unix.h index 9070de920..b51a12adf 100644 --- a/internal/glfw/glfw3_unix.h +++ b/internal/glfw/glfw3_unix.h @@ -249,7 +249,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. @@ -2412,8 +2412,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. @@ -3362,11 +3362,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 diff --git a/internal/glfw/input_unix.c b/internal/glfw/input_unix.c index 08ba0ed7e..099a35772 100644 --- a/internal/glfw/input_unix.c +++ b/internal/glfw/input_unix.c @@ -301,7 +301,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) { diff --git a/internal/glfw/nsgl_context_darwin.m b/internal/glfw/nsgl_context_darwin.m index 6b8545d4c..3d96557f5 100644 --- a/internal/glfw/nsgl_context_darwin.m +++ b/internal/glfw/nsgl_context_darwin.m @@ -137,7 +137,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; } diff --git a/internal/glfw/osmesa_context_unix.c b/internal/glfw/osmesa_context_unix.c index 950fbfa3c..787c3075b 100644 --- a/internal/glfw/osmesa_context_unix.c +++ b/internal/glfw/osmesa_context_unix.c @@ -5,13 +5,12 @@ //go:build darwin || freebsd || linux || netbsd || openbsd +#include "internal_unix.h" + #include #include #include -#include "internal_unix.h" - - static void makeContextCurrentOSMesa(_GLFWwindow* window) { if (window) diff --git a/internal/glfw/wgl_context_windows.go b/internal/glfw/wgl_context_windows.go index e16ec0bf8..305755f97 100644 --- a/internal/glfw/wgl_context_windows.go +++ b/internal/glfw/wgl_context_windows.go @@ -60,6 +60,18 @@ func (w *Window) choosePixelFormat(ctxconfig *ctxconfig, fbconfig_ *fbconfig) (i nativeCount = c if _glfw.platformContext.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 + var attrib int32 = _WGL_NUMBER_PIXEL_FORMATS_ARB + var extensionCount int32 + if err := wglGetPixelFormatAttribivARB(w.context.platform.dc, 1, 0, 1, &attrib, &extensionCount); err != nil { + return 0, fmt.Errorf("glfw: WGL: failed to retrieve pixel format attribute: %w", err) + } + if nativeCount > extensionCount { + nativeCount = extensionCount + } + attribs = append(attribs, _WGL_SUPPORT_OPENGL_ARB, _WGL_DRAW_TO_WINDOW_ARB, diff --git a/internal/glfw/win32_window_windows.go b/internal/glfw/win32_window_windows.go index 92ecbd173..3bba41122 100644 --- a/internal/glfw/win32_window_windows.go +++ b/internal/glfw/win32_window_windows.go @@ -2289,10 +2289,14 @@ func (w *Window) platformSetCursorMode(mode int) error { } func platformGetScancodeName(scancode int) (string, error) { - if scancode < 0 || scancode > (_KF_EXTENDED|0xff) || _glfw.platformWindow.keycodes[scancode] == KeyUnknown { + if scancode < 0 || scancode > (_KF_EXTENDED|0xff) { return "", fmt.Errorf("glwfwin: invalid scancode %d: %w", scancode, InvalidValue) } - return _glfw.platformWindow.keynames[_glfw.platformWindow.keycodes[scancode]], nil + key := _glfw.platformWindow.keycodes[scancode] + if key == KeyUnknown { + return "", nil + } + return _glfw.platformWindow.keynames[key], nil } func platformGetKeyScancode(key Key) int { diff --git a/internal/glfw/window_unix.c b/internal/glfw/window_unix.c index 494b557f1..1e1d4556d 100644 --- a/internal/glfw/window_unix.c +++ b/internal/glfw/window_unix.c @@ -676,7 +676,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); } diff --git a/internal/glfw/x11_window_linbsd.c b/internal/glfw/x11_window_linbsd.c index 3e72d4e3d..23e88a06f 100644 --- a/internal/glfw/x11_window_linbsd.c +++ b/internal/glfw/x11_window_linbsd.c @@ -2970,14 +2970,15 @@ 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)