From f764836e58ec47b7e105687630c75f8161ffcaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Aug 2019 16:59:54 +0200 Subject: [PATCH 01/56] Fix license copyright year and formatting --- LICENSE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index acdac20b..7494a3f6 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,5 +1,6 @@ Copyright (c) 2002-2006 Marcus Geelnard -Copyright (c) 2006-2016 Camilla Löwy + +Copyright (c) 2006-2019 Camilla Löwy This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages From 4cc5d2e62304432ee395b8d09f062c140810f340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 15 Aug 2019 17:25:36 +0200 Subject: [PATCH 02/56] Clarify comment --- src/win32_window.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index 0630f953..fbb05b6a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1276,9 +1276,9 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.scaleToMonitor = wndconfig->scaleToMonitor; - // Adjust window size to account for DPI scaling of the window frame and - // optionally DPI scaling of the content area - // This cannot be done until we know what monitor it was placed on + // Adjust window rect to account for DPI scaling of the window frame and + // (if enabled) DPI scaling of the content area + // This cannot be done until we know what monitor the window was placed on if (!window->monitor) { RECT rect = { 0, 0, wndconfig->width, wndconfig->height }; From 56ca0cb3b30ecb1310752360e9c875fc1b2bab5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 22 Aug 2019 21:31:46 +0200 Subject: [PATCH 03/56] Unify key name string handling This makes key names per-key static strings for all supported platforms. Fixes #1200. --- include/GLFW/glfw3.h | 6 ++++-- src/cocoa_platform.h | 2 +- src/cocoa_window.m | 10 ++++++---- src/x11_platform.h | 2 +- src/x11_window.c | 7 ++++--- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 72f93692..e8c9b154 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -4190,9 +4190,11 @@ GLFWAPI int glfwRawMouseMotionSupported(void); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * + * @remark The contents of the returned string may change when a keyboard + * layout change event is received. + * * @pointer_lifetime The returned string is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the next call to @ref - * glfwGetKeyName, or until the library is terminated. + * should not free it yourself. It is valid until the library is terminated. * * @thread_safety This function must only be called from the main thread. * diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index 97679732..f8bfe3e6 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -139,7 +139,7 @@ typedef struct _GLFWlibraryNS id keyUpMonitor; id nibObjects; - char keyName[64]; + char keynames[GLFW_KEY_LAST + 1][17]; short int keycodes[256]; short int scancodes[GLFW_KEY_LAST + 1]; char* clipboardString; diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 1674795c..49635c95 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1503,8 +1503,10 @@ const char* _glfwPlatformGetScancodeName(int scancode) { @autoreleasepool { + const int key = _glfw.ns.keycodes[scancode]; + UInt32 deadKeyState = 0; - UniChar characters[8]; + UniChar characters[4]; UniCharCount characterCount = 0; if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes], @@ -1529,12 +1531,12 @@ const char* _glfwPlatformGetScancodeName(int scancode) characterCount, kCFAllocatorNull); CFStringGetCString(string, - _glfw.ns.keyName, - sizeof(_glfw.ns.keyName), + _glfw.ns.keynames[key], + sizeof(_glfw.ns.keynames[key]), kCFStringEncodingUTF8); CFRelease(string); - return _glfw.ns.keyName; + return _glfw.ns.keynames[key]; } // autoreleasepool } diff --git a/src/x11_platform.h b/src/x11_platform.h index dbbe9d1f..33145e63 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -228,7 +228,7 @@ typedef struct _GLFWlibraryX11 // Clipboard string (while the selection is owned) char* clipboardString; // Key name string - char keyName[5]; + char keynames[GLFW_KEY_LAST + 1][5]; // X11 keycode to GLFW key LUT short int keycodes[256]; // GLFW key to X11 keycode LUT diff --git a/src/x11_window.c b/src/x11_window.c index 1398cb70..d8355ae8 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2792,6 +2792,7 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (!_glfw.x11.xkb.available) return NULL; + const int key = _glfw.x11.keycodes[scancode]; const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0); if (keysym == NoSymbol) @@ -2801,12 +2802,12 @@ const char* _glfwPlatformGetScancodeName(int scancode) if (ch == -1) return NULL; - const size_t count = encodeUTF8(_glfw.x11.keyName, (unsigned int) ch); + const size_t count = encodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch); if (count == 0) return NULL; - _glfw.x11.keyName[count] = '\0'; - return _glfw.x11.keyName; + _glfw.x11.keynames[key][count] = '\0'; + return _glfw.x11.keynames[key]; } int _glfwPlatformGetKeyScancode(int key) From cbf23e56151b2054003769760004dd581dda0ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 22 Aug 2019 23:39:47 +0200 Subject: [PATCH 04/56] Win32: Fix VS static analysis false positive This way is perhaps also more readable for humans. --- src/win32_monitor.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 988a3f95..3067b65e 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -477,7 +477,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) { HDC dc; - WORD values[768]; + WORD values[3][256]; dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL); GetDeviceGammaRamp(dc, values); @@ -485,9 +485,9 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) _glfwAllocGammaArrays(ramp, 256); - memcpy(ramp->red, values + 0, 256 * sizeof(unsigned short)); - memcpy(ramp->green, values + 256, 256 * sizeof(unsigned short)); - memcpy(ramp->blue, values + 512, 256 * sizeof(unsigned short)); + memcpy(ramp->red, values[0], sizeof(values[0])); + memcpy(ramp->green, values[1], sizeof(values[1])); + memcpy(ramp->blue, values[2], sizeof(values[2])); return GLFW_TRUE; } @@ -495,7 +495,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) { HDC dc; - WORD values[768]; + WORD values[3][256]; if (ramp->size != 256) { @@ -504,9 +504,9 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) return; } - memcpy(values + 0, ramp->red, 256 * sizeof(unsigned short)); - memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short)); - memcpy(values + 512, ramp->blue, 256 * sizeof(unsigned short)); + memcpy(values[0], ramp->red, sizeof(values[0])); + memcpy(values[1], ramp->green, sizeof(values[1])); + memcpy(values[2], ramp->blue, sizeof(values[2])); dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL); SetDeviceGammaRamp(dc, values); From 2777f6a754a469eb9b71b4d241ca5f3b1ce5a9b1 Mon Sep 17 00:00:00 2001 From: httpdigest Date: Sat, 31 Aug 2019 02:44:04 +0200 Subject: [PATCH 05/56] Fix comparison of video modes of equal area This fixes the bug of video modes being discarded if they had a different resolution but the same area as another mode. Fixes #1555. Closes #1556. --- src/monitor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/monitor.c b/src/monitor.c index 4f86cb80..394026f5 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -56,6 +56,10 @@ static int compareVideoModes(const void* fp, const void* sp) if (farea != sarea) return farea - sarea; + // Then sort on width + if (fm->width != sm->width) + return fm->width - sm->width; + // Lastly sort on refresh rate return fm->refreshRate - sm->refreshRate; } From 26aac53e1d07ad9996cde7a341c7713eaa1955b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 1 Sep 2019 20:05:58 +0200 Subject: [PATCH 06/56] Update changelog and add credit Related to #1556. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 09fb5f97..812b9c0b 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ information on what to include when reporting a bug. - Disabled tests and examples by default when built as a CMake subdirectory - 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) - [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 @@ -169,6 +170,7 @@ skills. - blanco - Kyle Brenneman - Rok Breulj + - Kai Burjack - Martin Capitanio - David Carlier - Arturo Castro From aa8e8ab960760fd3bbcb08f2a87be93c2f260aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 6 Sep 2019 15:23:20 +0200 Subject: [PATCH 07/56] Remove deprecated tags from Doxyfile.in This fixes warnings emitted by Doxygen 1.8.16. --- docs/Doxyfile.in | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 80ac3bd1..1c8618fd 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1632,11 +1632,6 @@ ALLEXTERNALS = NO EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- @@ -1649,15 +1644,6 @@ PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. From 7f02898264d6077738f0e8032f027eb7e252c90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 29 Aug 2019 22:08:29 +0200 Subject: [PATCH 08/56] Cocoa: Fix glfwSetWindowSize anchor point This makes glfwSetWindowSize use the top-left corner as anchor point instead of the bottom-left corner. Fixes #1553. --- README.md | 2 ++ src/cocoa_window.m | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 812b9c0b..0fb35bd4 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ information on what to include when reporting a bug. event (#1490) - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the window (#1499) + - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - [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) @@ -228,6 +229,7 @@ skills. - Peter Knut - Christoph Kubisch - Yuri Kunde Schlesner + - Rokas Kupstys - Konstantin Käfer - Eric Larson - Robin Leffmann diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 49635c95..dd8879b5 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1032,7 +1032,14 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) acquireMonitor(window); } else - [window->ns.object setContentSize:NSMakeSize(width, height)]; + { + NSRect contentRect = + [window->ns.object contentRectForFrameRect:[window->ns.object frame]]; + contentRect.origin.y += contentRect.size.height - height; + contentRect.size = NSMakeSize(width, height); + [window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect] + display:YES]; + } } // autoreleasepool } From 7105ff2dfd004a46bd732c1d0c9f461bae6d51b3 Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Mon, 12 Aug 2019 06:52:31 -0400 Subject: [PATCH 09/56] Fix typos Found via `codespell -q 3 -S ./deps -L fo,numer,te,uint,wille` --- docs/Doxyfile.in | 2 +- docs/input.dox | 2 +- examples/particles.c | 6 +++--- examples/splitview.c | 2 +- include/GLFW/glfw3.h | 14 +++++++------- src/win32_init.c | 4 ++-- src/wl_window.c | 2 +- tests/events.c | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 1c8618fd..825356d9 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1714,7 +1714,7 @@ UML_LOOK = NO # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be +# manageable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 diff --git a/docs/input.dox b/docs/input.dox index eb0244a7..dea64877 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -889,7 +889,7 @@ timer varies depending on the operating system and hardware. You can query the frequency, in Hz, with @ref glfwGetTimerFrequency. @code -uint64_t freqency = glfwGetTimerFrequency(); +uint64_t frequency = glfwGetTimerFrequency(); @endcode diff --git a/examples/particles.c b/examples/particles.c index 248c8516..9556ccac 100644 --- a/examples/particles.c +++ b/examples/particles.c @@ -444,7 +444,7 @@ static void draw_particles(GLFWwindow* window, double t, float dt) } // Set up vertex arrays. We use interleaved arrays, which is easier to - // handle (in most situations) and it gives a linear memeory access + // handle (in most situations) and it gives a linear memory access // access pattern (which may give better performance in some // situations). GL_T2F_C4UB_V3F means: 2 floats for texture coords, // 4 ubytes for color and 3 floats for vertex coord (in that order). @@ -654,7 +654,7 @@ static void draw_fountain(void) //======================================================================== -// Recursive function for building variable tesselated floor +// Recursive function for building variable tessellated floor //======================================================================== static void tessellate_floor(float x1, float y1, float x2, float y2, int depth) @@ -721,7 +721,7 @@ static void draw_floor(void) glMaterialfv(GL_FRONT, GL_SPECULAR, floor_specular); glMaterialf(GL_FRONT, GL_SHININESS, floor_shininess); - // Draw floor as a bunch of triangle strips (high tesselation + // Draw floor as a bunch of triangle strips (high tessellation // improves lighting) glNormal3f(0.f, 0.f, 1.f); glBegin(GL_QUADS); diff --git a/examples/splitview.c b/examples/splitview.c index 58eb11ef..58441dbb 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -3,7 +3,7 @@ // // The program uses a "split window" view, rendering four views of the // same scene in one window (e.g. uesful for 3D modelling software). This -// demo uses scissors to separete the four different rendering areas from +// demo uses scissors to separate the four different rendering areas from // each other. // // (If the code seems a little bit strange here and there, it may be diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index e8c9b154..dad45a49 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2041,7 +2041,7 @@ GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); */ GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); -/*! @brief Retrives the work area of the monitor. +/*! @brief Retrieves the work area of the monitor. * * This function returns the position, in screen coordinates, of the upper-left * corner of the work area of the specified monitor along with the work area @@ -2325,7 +2325,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR. * - * @remark @wayland Gamma handling is a priviledged protocol, this function + * @remark @wayland Gamma handling is a privileged protocol, this function * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR. * * @thread_safety This function must only be called from the main thread. @@ -2349,7 +2349,7 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref * GLFW_PLATFORM_ERROR. * - * @remark @wayland Gamma handling is a priviledged protocol, this function + * @remark @wayland Gamma handling is a privileged protocol, this function * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while * returning `NULL`. * @@ -2393,7 +2393,7 @@ GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); * * @remark @win32 The gamma ramp size must be 256. * - * @remark @wayland Gamma handling is a priviledged protocol, this function + * @remark @wayland Gamma handling is a privileged protocol, this function * will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR. * * @pointer_lifetime The specified gamma ramp is copied before this function @@ -2612,7 +2612,7 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * * @remark @macos When activating frame autosaving with * [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified - * window size and position may be overriden by previously saved values. + * window size and position may be overridden by previously saved values. * * @remark @x11 Some window managers will not respect the placement of * initially hidden windows. @@ -4984,7 +4984,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count); */ GLFWAPI const char* glfwGetJoystickName(int jid); -/*! @brief Returns the SDL comaptible GUID of the specified joystick. +/*! @brief Returns the SDL compatible GUID of the specified joystick. * * This function returns the SDL compatible GUID, as a UTF-8 encoded * hexadecimal string, of the specified joystick. The returned string is @@ -5205,7 +5205,7 @@ GLFWAPI const char* glfwGetGamepadName(int jid); /*! @brief Retrieves the state of the specified joystick remapped as a gamepad. * - * This function retrives the state of the specified joystick remapped to + * This function retrieves the state of the specified joystick remapped to * an Xbox-like gamepad. * * If the specified joystick is not present or does not have a gamepad mapping diff --git a/src/win32_init.c b/src/win32_init.c index 950a52a3..260e888e 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -525,7 +525,7 @@ BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp) cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL); cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the - // latter lies unless the user knew to embedd a non-default manifest + // latter lies unless the user knew to embed a non-default manifest // announcing support for Windows 10 via supportedOS GUID return RtlVerifyVersionInfo(&osvi, mask, cond) == 0; } @@ -540,7 +540,7 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build) cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL); cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL); // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the - // latter lies unless the user knew to embedd a non-default manifest + // latter lies unless the user knew to embed a non-default manifest // announcing support for Windows 10 via supportedOS GUID return RtlVerifyVersionInfo(&osvi, mask, cond) == 0; } diff --git a/src/wl_window.c b/src/wl_window.c index 5c7011fd..200b004c 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -68,7 +68,7 @@ static int createTmpfileCloexec(char* tmpname) * SCM_RIGHTS methods. * * posix_fallocate() is used to guarantee that disk space is available - * for the file at the given size. If disk space is insufficent, errno + * for the file at the given size. If disk space is insufficient, errno * is set to ENOSPC. If posix_fallocate() is not supported, program may * receive SIGBUS on accessing mmap()'ed file contents instead. */ diff --git a/tests/events.c b/tests/events.c index ba7f00ab..251e15d9 100644 --- a/tests/events.c +++ b/tests/events.c @@ -175,7 +175,7 @@ static const char* get_key_name(int key) case GLFW_KEY_KP_8: return "KEYPAD 8"; case GLFW_KEY_KP_9: return "KEYPAD 9"; case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE"; - case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTPLY"; + case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTIPLY"; case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT"; case GLFW_KEY_KP_ADD: return "KEYPAD ADD"; case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL"; From 243b1bc292a2e3f8c9aee8884574c1c7f4354402 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 25 Jul 2019 16:55:19 -0500 Subject: [PATCH 10/56] Use the correct type in a for loop The `size` member in the `GLFWgammaramp` struct is of type `unsigned int`, so the `for` loop iterating over it should also use the type `unsigned int`. Closes #1541. --- src/cocoa_monitor.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index f1a63e3e..a3458152 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -528,7 +528,7 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue)); - for (int i = 0; i < ramp->size; i++) + for (unsigned int i = 0; i < ramp->size; i++) { values[i] = ramp->red[i] / 65535.f; values[i + ramp->size] = ramp->green[i] / 65535.f; From 3ec8f4a7f5ae83089b5f693fb97d3eb384aa33d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 3 Oct 2019 19:49:25 +0200 Subject: [PATCH 11/56] Win32: Disable dynamic libgcc for MinGW DLL --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 80ee9691..06867308 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,6 +125,10 @@ target_compile_options(glfw PRIVATE if (BUILD_SHARED_LIBS) if (WIN32) if (MINGW) + # Remove the dependency on the shared version of libgcc + # NOTE: MinGW-w64 has the correct default but MinGW needs this + target_link_options(glfw PRIVATE "-static-libgcc") + # Remove the lib prefix on the DLL (but not the import library) set_target_properties(glfw PROPERTIES PREFIX "") From 3d2540c373c53a8ddfba806fb83cdb9e39a61467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 13 Sep 2019 01:16:13 +0200 Subject: [PATCH 12/56] Win32: Cleanup keyboard input flag parsing This replaces some magic numbers with the corresponding winuser.h provided macros and unifies how the MSB from Get*KeyState is tested. --- src/win32_window.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/win32_window.c b/src/win32_window.c index fbb05b6a..efb4e043 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -481,7 +481,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam) DWORD time; // Right side keys have the extended key bit set - if (lParam & 0x01000000) + if (HIWORD(lParam) & KF_EXTENDED) return GLFW_KEY_RIGHT_CONTROL; // HACK: Alt Gr sends Left Ctrl and then Right Alt in close sequence @@ -497,7 +497,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam) next.message == WM_SYSKEYUP) { if (next.wParam == VK_MENU && - (next.lParam & 0x01000000) && + (HIWORD(next.lParam) & KF_EXTENDED) && next.time == time) { // Next message is Right Alt down so discard this @@ -740,8 +740,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_SYSKEYUP: { const int key = translateKey(wParam, lParam); - const int scancode = (lParam >> 16) & 0x1ff; - const int action = ((lParam >> 31) & 1) ? GLFW_RELEASE : GLFW_PRESS; + const int scancode = (HIWORD(lParam) & 0x1ff); + const int action = (HIWORD(lParam) & KF_UP) ? GLFW_RELEASE : GLFW_PRESS; const int mods = getKeyMods(); if (key == _GLFW_KEY_INVALID) @@ -1934,8 +1934,8 @@ void _glfwPlatformPollEvents(void) window = GetPropW(handle, L"GLFW"); if (window) { - const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1; - const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1; + const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) & 0x8000) != 0; + const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) & 0x8000) != 0; if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS) { From 1bd0a55aa76ceeda0537f7483bda1163405aa571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 2 Oct 2019 22:41:02 +0200 Subject: [PATCH 13/56] Add VS 2010 and MinGW to AppVeyor build matrix VS 2010 and MinGW are the two trickiest Windows environments so this should hopefully catch more mistakes. This is probably not the right way to set up any of this, but it works for now. This is also a first step towards building our release binaries with CI. [skip travis] --- .appveyor.yml | 52 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index f8aaf42d..a21829a6 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,3 +1,6 @@ +image: + - Visual Studio 2015 + - Visual Studio 2019 branches: only: - ci @@ -5,17 +8,50 @@ branches: - 3.3-stable skip_tags: true environment: - CFLAGS: /WX matrix: - - BUILD_SHARED_LIBS: ON - - BUILD_SHARED_LIBS: OFF + - GENERATOR: MinGW Makefiles + BUILD_SHARED_LIBS: ON + CFLAGS: -Werror + - GENERATOR: MinGW Makefiles + BUILD_SHARED_LIBS: OFF + CFLAGS: -Werror + - GENERATOR: Visual Studio 10 2010 + BUILD_SHARED_LIBS: ON + CFLAGS: /WX + - GENERATOR: Visual Studio 10 2010 + BUILD_SHARED_LIBS: OFF + CFLAGS: /WX + - GENERATOR: Visual Studio 16 2019 + BUILD_SHARED_LIBS: ON + CFLAGS: /WX + - GENERATOR: Visual Studio 16 2019 + BUILD_SHARED_LIBS: OFF + CFLAGS: /WX matrix: fast_finish: true -build_script: - - mkdir build - - cd build - - cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% .. - - cmake --build . + exclude: + - image: Visual Studio 2015 + GENERATOR: Visual Studio 16 2019 + - image: Visual Studio 2019 + GENERATOR: Visual Studio 10 2010 + - image: Visual Studio 2019 + GENERATOR: MinGW Makefiles +for: +- + matrix: + except: + - GENERATOR: Visual Studio 10 2010 + build_script: + - set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin% + - cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% + - cmake --build build +- + matrix: + only: + - GENERATOR: Visual Studio 10 2010 + build_script: + - cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% + - cmake --build build --target glfw notifications: - provider: Email to: From d25248343e248337284dfbe5ecd1eddbd37ae66d Mon Sep 17 00:00:00 2001 From: Luflosi Date: Mon, 30 Sep 2019 23:17:42 +0200 Subject: [PATCH 14/56] Use the correct type for a struct member The `name` member in the `_GLFWmonitorWayland` struct is used in two places. It is assigned the value from a variable of type `uint32_t` and is compared to another variable of type `uint32_t`, so `name` should also have the same type. Closes #1569. --- src/wl_platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wl_platform.h b/src/wl_platform.h index 13f4ab31..22298303 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -330,7 +330,7 @@ typedef struct _GLFWlibraryWayland typedef struct _GLFWmonitorWayland { struct wl_output* output; - int name; + uint32_t name; int currentMode; int x; From f71b55f83d5666c17d9a3ef057397b8f49704039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 10 Oct 2019 18:03:28 +0200 Subject: [PATCH 15/56] Clean up monitors tool output --- tests/monitors.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/monitors.c b/tests/monitors.c index 30ce4088..2b75d7b1 100644 --- a/tests/monitors.c +++ b/tests/monitors.c @@ -109,13 +109,13 @@ static void list_modes(GLFWmonitor* monitor) glfwGetMonitorName(monitor), glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary"); printf("Current mode: %s\n", format_mode(mode)); - printf("Virtual position: %i %i\n", x, y); - printf("Content scale: %f %f\n", xscale, yscale); + printf("Virtual position: %i, %i\n", x, y); + printf("Content scale: %f x %f\n", xscale, yscale); - printf("Physical size: %i x %i mm (%0.2f dpi)\n", - width_mm, height_mm, mode->width * 25.4f / width_mm); - printf("Monitor work area: pos=(%d,%d) size=(%dx%d)\n", - workarea_x, workarea_y, workarea_width, workarea_height); + printf("Physical size: %i x %i mm (%0.2f dpi at %i x %i)\n", + width_mm, height_mm, mode->width * 25.4f / width_mm, mode->width, mode->height); + printf("Monitor work area: %i x %i starting at %i, %i\n", + workarea_width, workarea_height, workarea_x, workarea_y); printf("Modes:\n"); From 8f852e0833be7fa762d70c804c7856b537da9376 Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Thu, 5 Sep 2019 09:47:49 -0400 Subject: [PATCH 16/56] Enable C99 explicitly with CMake where available This enables compilation as C99 where supported by the compiler. A workaround with per-compiler hardcoded flags is used for CMake 3.0, which does not support the C_STANDARD target property. Fixes #1560. Closes #1576. --- src/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06867308..0af6dd05 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,6 +100,16 @@ set_target_properties(glfw PROPERTIES POSITION_INDEPENDENT_CODE ON FOLDER "GLFW3") +if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.1.0") + set_target_properties(glfw PROPERTIES C_STANDARD 99) +else() + # Remove this fallback when removing support for CMake version less than 3.1 + target_compile_options(glfw PRIVATE + "$<$:-std=c99>" + "$<$:-std=c99>>" + "$<$:-std=c99>>") +endif() + target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) target_include_directories(glfw PUBLIC "$" From 545f4095921273e9c3ea562b95f331f77f2202b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 10 Oct 2019 20:12:42 +0200 Subject: [PATCH 17/56] Add credit Related to #1576. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0fb35bd4..ff33eb88 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,7 @@ skills. - Nathan Poirier - Alexandre Pretyman - przemekmirek + - Guillaume Racicot - Philip Rideout - Eddie Ringle - Max Risuhin From 1e20218b3da47691ab5589592f41ce50856f7273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 13 Oct 2019 16:42:54 +0200 Subject: [PATCH 18/56] Use HTTPS for Discourse forum --- README.md | 2 +- docs/CONTRIBUTING.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ff33eb88..edd6560d 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ On [glfw.org](http://www.glfw.org/) you can find the latest version of GLFW, as well as news, documentation and other information about the project. If you have questions related to the use of GLFW, we have a -[forum](http://discourse.glfw.org/), and the `#glfw` IRC channel on +[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on [Freenode](http://freenode.net/). If you have a bug to report, a patch to submit or a feature you'd like to diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 3bee43b9..070cff95 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -20,14 +20,14 @@ ## Asking a question Questions about how to use GLFW should be asked either in the [support -section](http://discourse.glfw.org/c/support) of the forum, under the [Stack +section](https://discourse.glfw.org/c/support) of the forum, under the [Stack Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on Stack Exchange or in the IRC channel `#glfw` on [Freenode](http://freenode.net/). Questions about the design or implementation of GLFW or about future plans -should be asked in the [dev section](http://discourse.glfw.org/c/dev) of the +should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the forum or in the IRC channel. Please don't open a GitHub issue to discuss design questions without first checking with a maintainer. From 7749aac50dd404b53ac5c1b35b7935b660ecdad7 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 6 Oct 2019 22:56:58 +0200 Subject: [PATCH 19/56] Use the correct type in a for loop The `monitorCount` member in the `_GLFWlibrary` struct is of type `int`, so the `for` loop iterating over it should also use the type `int`. Closes #1572. --- src/cocoa_monitor.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index a3458152..9ef2cdc9 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -252,7 +252,7 @@ void _glfwPollMonitorsNS(void) CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID)); CGGetOnlineDisplayList(displayCount, displays, &displayCount); - for (uint32_t i = 0; i < _glfw.monitorCount; i++) + for (int i = 0; i < _glfw.monitorCount; i++) _glfw.monitors[i]->ns.screen = nil; _GLFWmonitor** disconnected = NULL; From 3a37a089982ba66f69d3b8e15ec8c769621f7f12 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Sun, 15 Sep 2019 08:57:34 -0400 Subject: [PATCH 20/56] Fix -Wextra-semi warnings Closes #1440. --- README.md | 1 + src/cocoa_joystick.h | 2 +- src/null_joystick.h | 4 ++-- src/null_platform.h | 14 +++++++------- src/win32_joystick.h | 2 +- src/wl_platform.h | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index edd6560d..5fd18e4f 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ information on what to include when reporting a bug. - 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: Fix -Wextra-semi compilation warning (#1440) - [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 diff --git a/src/cocoa_joystick.h b/src/cocoa_joystick.h index ce98221a..9bf5cde4 100644 --- a/src/cocoa_joystick.h +++ b/src/cocoa_joystick.h @@ -30,7 +30,7 @@ #include #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; } #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" diff --git a/src/null_joystick.h b/src/null_joystick.h index 2adea420..5d19a451 100644 --- a/src/null_joystick.h +++ b/src/null_joystick.h @@ -24,8 +24,8 @@ // //======================================================================== -#define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs +#define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; } +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } #define _GLFW_PLATFORM_MAPPING_NAME "" diff --git a/src/null_platform.h b/src/null_platform.h index d844488f..fdea9906 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -29,13 +29,13 @@ #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null -#define _GLFW_PLATFORM_CONTEXT_STATE -#define _GLFW_PLATFORM_MONITOR_STATE -#define _GLFW_PLATFORM_CURSOR_STATE -#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE -#define _GLFW_EGL_CONTEXT_STATE -#define _GLFW_EGL_LIBRARY_CONTEXT_STATE +#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } +#define _GLFW_PLATFORM_MONITOR_STATE struct { int dummyMonitor; } +#define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; } +#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE struct { int dummyLibraryWindow; } +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } +#define _GLFW_EGL_CONTEXT_STATE struct { int dummyEGLContext; } +#define _GLFW_EGL_LIBRARY_CONTEXT_STATE struct { int dummyEGLLibraryContext; } #include "osmesa_context.h" #include "posix_time.h" diff --git a/src/win32_joystick.h b/src/win32_joystick.h index f6384a41..f593274e 100644 --- a/src/win32_joystick.h +++ b/src/win32_joystick.h @@ -25,7 +25,7 @@ //======================================================================== #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 -#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int dummy +#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; } #define _GLFW_PLATFORM_MAPPING_NAME "Windows" diff --git a/src/wl_platform.h b/src/wl_platform.h index 22298303..894a4e68 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -75,8 +75,8 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl -#define _GLFW_PLATFORM_CONTEXT_STATE -#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE +#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } +#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } struct wl_cursor_image { uint32_t width; From 692754a2c5e37f6384aefec327ad52c58f45216c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 16 Oct 2019 16:49:37 +0200 Subject: [PATCH 21/56] Allow AppVeyor to skip pure documentation updates --- .appveyor.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.appveyor.yml b/.appveyor.yml index a21829a6..2f4532eb 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,6 +7,11 @@ branches: - master - 3.3-stable skip_tags: true +skip_commits: + files: + - README.md + - LICENSE.md + - docs/* environment: matrix: - GENERATOR: MinGW Makefiles From 36c547875c3db6bea9e1e7d5ed8a633771dde774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 16 Oct 2019 17:43:29 +0200 Subject: [PATCH 22/56] Update changelog --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5fd18e4f..3ac0f645 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ information on what to include when reporting a bug. - 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: Fix -Wextra-semi compilation warning (#1440) + - Bugfix: Compiling with -Wextra-semi caused warnings (#1440) - [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 From 376897a344b53fbb7397b7466fe9499f1aeab6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Oct 2019 13:17:47 +0200 Subject: [PATCH 23/56] Replace notes for previous releases with links The news / release notes page was getting a bit long. --- docs/news.dox | 851 +------------------------------------------------- 1 file changed, 5 insertions(+), 846 deletions(-) diff --git a/docs/news.dox b/docs/news.dox index f551bb94..e3063c63 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -36,852 +36,11 @@ add_subdirectory(path/to/glfw) @subsubsection constants_34 New constants in version 3.4 -@section news_33 Release notes for version 3.3 +@section news_archive Release notes for earlier versions -These are the release notes for version 3.3. For a more detailed view including -all fixed bugs see the [version history](https://www.glfw.org/changelog.html). - -Please review the caveats, deprecations and removals if your project was written -against an earlier version of GLFW 3. - - -@subsection features_33 New features in version 3.3 - -@subsubsection gamepad_33 Gamepad input via SDL_GameControllerDB - -GLFW can now remap game controllers to a standard Xbox-like layout using -a built-in copy of SDL_GameControllerDB. Call @ref glfwJoystickIsGamepad to -check if a joystick has a mapping, @ref glfwGetGamepadState to retrieve its -input state, @ref glfwUpdateGamepadMappings to add newer mappings and @ref -glfwGetGamepadName and @ref glfwGetJoystickGUID for mapping related information. - -For more information see @ref gamepad. - - -@subsubsection moltenvk_33 Support for Vulkan on macOS via MoltenVK - -GLFW now supports [MoltenVK](https://moltengl.com/moltenvk/), a Vulkan -implementation on top of the Metal API, and its `VK_MVK_macos_surface` window -surface creation extension. MoltenVK is included in the [macOS Vulkan -SDK](https://vulkan.lunarg.com/). - -For more information see @ref vulkan_guide. - - -@subsubsection content_scale_33 Content scale queries for DPI-aware rendering - -GLFW now provides content scales for windows and monitors, i.e. the ratio -between their current DPI and the platform's default DPI, with @ref -glfwGetWindowContentScale and @ref glfwGetMonitorContentScale. - -Changes of the content scale of a window can be received with the window content -scale callback, set with @ref glfwSetWindowContentScaleCallback. - -The @ref GLFW_SCALE_TO_MONITOR window hint enables automatic resizing of a -window by the content scale of the monitor it is placed, on platforms like -Windows where this is necessary. This takes effect both on creation and when -the window is moved between monitors. It is related to but different from -[GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint). - -For more information see @ref window_scale. - - -@subsubsection setwindowattrib_33 Support for updating window attributes - -GLFW now supports changing the [GLFW_DECORATED](@ref GLFW_DECORATED_attrib), -[GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib), -[GLFW_FLOATING](@ref GLFW_FLOATING_attrib), -[GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and -[GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib) attributes for existing -windows with @ref glfwSetWindowAttrib. - -For more information see @ref window_attribs. - - -@subsubsection raw_motion_33 Support for raw mouse motion - -GLFW now supports raw (unscaled and unaccelerated) mouse motion in disabled -cursor mode with the [GLFW_RAW_MOUSE_MOTION](@ref GLFW_RAW_MOUSE_MOTION) input -mode. Raw mouse motion input is not yet implemented on macOS. Call @ref -glfwRawMouseMotionSupported to check if GLFW can provide raw mouse motion on the -current system. - -For more information see @ref raw_mouse_motion. - - -@subsubsection joysticks_33 Joystick hats - -GLFW can now return the state of hats (i.e. POVs or D-pads) of a joystick with -@ref glfwGetJoystickHats. For compatibility, hats are also exposed as buttons. -This can be disabled with the @ref GLFW_JOYSTICK_HAT_BUTTONS initialization -hint. - -For more information see @ref joystick_hat. - - -@subsubsection geterror_33 Error query - -GLFW now supports querying the last error code for the calling thread and its -human-readable description with @ref glfwGetError. This can be used instead of -or together with the error callback. - -For more information see @ref error_handling. - - -@subsubsection init_hints_33 Support for initialization hints - -GLFW now supports setting library initialization hints with @ref glfwInitHint. -These must be set before initialization to take effect. Some of these hints are -platform specific but are safe to set on any platform. - -For more information see @ref init_hints. - - -@subsubsection attention_33 User attention request - -GLFW now supports requesting user attention with @ref -glfwRequestWindowAttention. Where possible this calls attention to the -specified window. On platforms like macOS it calls attention to the whole -application. - -For more information see @ref window_attention. - - -@subsubsection maximize_33 Window maximization callback - -GLFW now supports notifying the application that the window has been maximized -@ref glfwSetWindowMaximizeCallback. This is called both when the window was -maximized by the user and when it was done with @ref glfwMaximizeWindow. - -For more information see @ref window_maximize. - - -@subsubsection workarea_33 Query for the monitor work area - -GLFW now supports querying the work area of a monitor, i.e. the area not -occupied by task bars or global menu bars, with @ref glfwGetMonitorWorkarea. On -platforms that lack this concept, the whole area of the monitor is returned. - -For more information see @ref monitor_workarea. - - -@subsubsection transparency_33 Transparent windows and framebuffers - -GLFW now supports the creation of windows with transparent framebuffers on -systems with desktop compositing enabled with the @ref -GLFW_TRANSPARENT_FRAMEBUFFER window hint and attribute. This hint must be set -before window creation and leaves any window decorations opaque. - -GLFW now also supports whole window transparency with @ref glfwGetWindowOpacity -and @ref glfwSetWindowOpacity. This value controls the opacity of the whole -window including decorations and unlike framebuffer transparency can be changed -at any time after window creation. - -For more information see @ref window_transparency. - - -@subsubsection key_scancode_33 Query for the scancode of a key - -GLFW now supports querying the platform dependent scancode of any physical key -with @ref glfwGetKeyScancode. - -For more information see @ref input_key. - - -@subsubsection center_cursor_33 Cursor centering window hint - -GLFW now supports controlling whether the cursor is centered over newly created -full screen windows with the [GLFW_CENTER_CURSOR](@ref GLFW_CENTER_CURSOR_hint) -window hint. It is enabled by default. - - -@subsubsection cursor_hover_33 Mouse cursor hover window attribute - -GLFW now supports polling whether the cursor is hovering over the window content -area with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute. This -attribute corresponds to the [cursor enter/leave](@ref cursor_enter) event. - - -@subsubsection focusonshow_33 Window hint and attribute for input focus on show - -GLFW now has the [GLFW_FOCUS_ON_SHOW](@ref GLFW_DECORATED_hint) window hint and -attribute for controlling whether a window gets input focus when shown. It is -enabled by default. It applies both when creating an visible window with @ref -glfwCreateWindow and when showing it with @ref glfwShowWindow. - -This is a workaround for GLFW 3.0 lacking @ref glfwFocusWindow and will be -corrected in the next major version. - -For more information see @ref window_hide. - - -@subsubsection device_userptr_33 Monitor and joystick user pointers - -GLFW now supports setting and querying user pointers for connected monitors and -joysticks with @ref glfwSetMonitorUserPointer, @ref glfwGetMonitorUserPointer, -@ref glfwSetJoystickUserPointer and @ref glfwGetJoystickUserPointer. - -For more information see @ref monitor_userptr and @ref joystick_userptr. - - -@subsubsection macos_nib_33 macOS menu bar from nib file - -GLFW will now load a `MainMenu.nib` file if found in the `Contents/Resources` -directory of the application bundle, as a way to replace the GLFW menu bar -without recompiling GLFW. This behavior can be disabled with the -[GLFW_COCOA_MENUBAR](@ref GLFW_COCOA_MENUBAR_hint) initialization hint. - - -@subsubsection glext_33 Support for more context creation extensions - -The context hint @ref GLFW_SRGB_CAPABLE now supports OpenGL ES via -`WGL_EXT_colorspace`, the context hint @ref GLFW_CONTEXT_NO_ERROR now supports -`WGL_ARB_create_context_no_error` and `GLX_ARB_create_context_no_error`, the -context hint @ref GLFW_CONTEXT_RELEASE_BEHAVIOR now supports -`EGL_KHR_context_flush_control` and @ref glfwGetProcAddress now supports -`EGL_KHR_get_all_proc_addresses`. - - -@subsubsection osmesa_33 OSMesa off-screen context creation support - -GLFW now supports creating off-screen OpenGL contexts using -[OSMesa](https://www.mesa3d.org/osmesa.html) by setting -[GLFW_CONTEXT_CREATION_API](@ref GLFW_CONTEXT_CREATION_API_hint) to -`GLFW_OSMESA_CONTEXT_API`. Native access function have been added to retrieve -the OSMesa color and depth buffers. - -There is also a new null backend that uses OSMesa as its native context -creation API, intended for automated testing. This backend does not provide -input. - - -@subsection caveats_33 Caveats for version 3.3 - -@subsubsection joystick_layout_33 Layout of joysticks have changed - -The way joystick elements are arranged have changed to match SDL2 in order to -support SDL_GameControllerDB mappings. The layout of joysticks may -change again if required for compatibility with SDL2. If you need a known and -stable layout for game controllers, see if you can switch to @ref gamepad. - -Existing code that depends on a specific joystick layout will likely have to be -updated. - - -@subsubsection wait_events_33 No window required to wait for events - -The @ref glfwWaitEvents and @ref glfwWaitEventsTimeout functions no longer need -a window to be created to wait for events. Before version 3.3 these functions -would return immediately if there were no user-created windows. On platforms -where only windows can receive events, an internal helper window is used. - -Existing code that depends on the earlier behavior will likely have to be -updated. - - -@subsubsection gamma_ramp_size_33 Gamma ramp size of 256 may be rejected - -The documentation for versions before 3.3 stated that a gamma ramp size of 256 -would always be accepted. This was never the case on X11 and could lead to -artifacts on macOS. The @ref glfwSetGamma function has been updated to always -generate a ramp of the correct size. - -Existing code that hardcodes a size of 256 should be updated to use the size of -the current ramp of a monitor when setting a new ramp for that monitor. - - -@subsubsection xinput_deadzone_33 Windows XInput deadzone removed - -GLFW no longer applies any deadzone to the input state received from the XInput -API. This was never done for any other platform joystick API so this change -makes the behavior more consistent but you will need to apply your own deadzone -if desired. - - -@subsubsection x11_clipboard_33 X11 clipboard transfer limits - -GLFW now supports reading clipboard text via the `INCR` method, which removes -the limit on how much text can be read with @ref glfwGetClipboardString. -However, writing via this method is not yet supported, so you may not be able to -write a very large string with @ref glfwSetClipboardString even if you read it -from the clipboard earlier. - -The exact size limit for writing to the clipboard is negotiated with each -receiving application but is at least several tens of kilobytes. Note that only -the read limit has changed. Any string that could be written before still can -be. - - -@subsubsection x11_linking_33 X11 extension libraries are loaded dynamically - -GLFW now loads all X11 extension libraries at initialization. The only X11 -library you need to link against is `libX11`. The header files for the -extension libraries are still required for compilation. - -Existing projects and makefiles that link GLFW directly against the extension -libraries should still build correctly but will add these libraries as load-time -dependencies. - - -@subsubsection cmake_version_33 CMake 3.0 or later is required - -The minimum CMake version has been raised from 2.8.12 to 3.0. This is only -a requirement of the GLFW CMake files. The GLFW source files do not depend on -CMake. - - -@subsection deprecations_33 Deprecations in version 3.3 - -@subsubsection charmods_callback_33 Character with modifiers callback - -The character with modifiers callback set with @ref glfwSetCharModsCallback has -been deprecated and should if possible not be used. - -Existing code should still work but further bug fixes will likely not be made. -The callback will be removed in the next major version. - - -@subsubsection clipboard_window_33 Window parameter to clipboard functions - -The window parameter of the clipboard functions @ref glfwGetClipboardString and -@ref glfwSetClipboardString has been deprecated and is no longer used on any -platform. On platforms where the clipboard must be owned by a specific window, -an internal helper window is used. - -Existing code should still work unless it depends on a specific window owning -the clipboard. New code may pass `NULL` as the window argument. The parameter -will be removed in a future release. - - -@subsection removals_33 Removals in 3.3 - -@subsubsection macos_options_33 macOS specific CMake options and macros - -The `GLFW_USE_RETINA`, `GLFW_USE_CHDIR` and `GLFW_USE_MENUBAR` CMake options and -the `_GLFW_USE_RETINA`, `_GLFW_USE_CHDIR` and `_GLFW_USE_MENUBAR` compile-time -macros have been removed. - -These options and macros are replaced by the window hint -[GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint) -and the init hints -[GLFW_COCOA_CHDIR_RESOURCES](@ref GLFW_COCOA_CHDIR_RESOURCES_hint) and -[GLFW_COCOA_MENUBAR](@ref GLFW_COCOA_MENUBAR_hint). - -Existing projects and makefiles that set these options or define these macros -during compilation of GLFW will still build but it will have no effect and the -default behaviors will be used. - - -@subsubsection vulkan_sdk_33 LunarG Vulkan SDK dependency - -The GLFW test programs that previously depended on the LunarG Vulkan SDK now -instead uses a Vulkan loader generated by -[glad2](https://github.com/Dav1dde/glad). This means the GLFW CMake files no -longer look for the Vulkan SDK. - -Existing CMake projects that depended on the Vulkan SDK cache variables from -GLFW will need to call `find_package(Vulkan)` themselves. CMake 3.7 and later -already comes with a -[Vulkan find module](https://cmake.org/cmake/help/latest/module/FindVulkan.html) -similar to the one GLFW previously included. - - -@subsubsection lib_suffix_33 CMake option LIB_SUFFIX - -The `LIB_SUFFIX` CMake option has been removed. GLFW now uses the -GNUInstallDirs CMake package to handle platform specific details like the -library directory suffix and the `LIB_SUFFIX` CMake option has been removed. - -Existing projects and makefiles that set the `LIB_SUFFIX` option will use the -suffix chosen by the GNUInstallDirs package and the option will be ignored. - - -@subsubsection mir_removed_33 Mir support - -The experimental Mir support has been completely removed as the Mir project has -implemented support for the Wayland protocol and is recommending that -applications use that instead. - -Existing projects and makefiles that select Mir when compiling GLFW will fail. -Use Wayland or X11 instead. - - -@subsection symbols_33 New symbols in version 3.3 - -@subsubsection functions_33 New functions in version 3.3 - - - @ref glfwInitHint - - @ref glfwGetError - - @ref glfwGetMonitorWorkarea - - @ref glfwGetMonitorContentScale - - @ref glfwGetMonitorUserPointer - - @ref glfwSetMonitorUserPointer - - @ref glfwWindowHintString - - @ref glfwGetWindowContentScale - - @ref glfwGetWindowOpacity - - @ref glfwSetWindowOpacity - - @ref glfwRequestWindowAttention - - @ref glfwSetWindowAttrib - - @ref glfwSetWindowMaximizeCallback - - @ref glfwSetWindowContentScaleCallback - - @ref glfwRawMouseMotionSupported - - @ref glfwGetKeyScancode - - @ref glfwGetJoystickHats - - @ref glfwGetJoystickGUID - - @ref glfwGetJoystickUserPointer - - @ref glfwSetJoystickUserPointer - - @ref glfwJoystickIsGamepad - - @ref glfwUpdateGamepadMappings - - @ref glfwGetGamepadName - - @ref glfwGetGamepadState - - -@subsubsection types_33 New types in version 3.3 - - - @ref GLFWwindowmaximizefun - - @ref GLFWwindowcontentscalefun - - @ref GLFWgamepadstate - - -@subsubsection constants_33 New constants in version 3.3 - - - @ref GLFW_NO_ERROR - - @ref GLFW_JOYSTICK_HAT_BUTTONS - - @ref GLFW_COCOA_CHDIR_RESOURCES - - @ref GLFW_COCOA_MENUBAR - - @ref GLFW_CENTER_CURSOR - - @ref GLFW_TRANSPARENT_FRAMEBUFFER - - @ref GLFW_HOVERED - - @ref GLFW_FOCUS_ON_SHOW - - @ref GLFW_SCALE_TO_MONITOR - - @ref GLFW_COCOA_RETINA_FRAMEBUFFER - - @ref GLFW_COCOA_FRAME_NAME - - @ref GLFW_COCOA_GRAPHICS_SWITCHING - - @ref GLFW_X11_CLASS_NAME - - @ref GLFW_X11_INSTANCE_NAME - - @ref GLFW_OSMESA_CONTEXT_API - - @ref GLFW_HAT_CENTERED - - @ref GLFW_HAT_UP - - @ref GLFW_HAT_RIGHT - - @ref GLFW_HAT_DOWN - - @ref GLFW_HAT_LEFT - - @ref GLFW_HAT_RIGHT_UP - - @ref GLFW_HAT_RIGHT_DOWN - - @ref GLFW_HAT_LEFT_UP - - @ref GLFW_HAT_LEFT_DOWN - - @ref GLFW_MOD_CAPS_LOCK - - @ref GLFW_MOD_NUM_LOCK - - @ref GLFW_LOCK_KEY_MODS - - @ref GLFW_RAW_MOUSE_MOTION - - @ref GLFW_GAMEPAD_BUTTON_A - - @ref GLFW_GAMEPAD_BUTTON_B - - @ref GLFW_GAMEPAD_BUTTON_X - - @ref GLFW_GAMEPAD_BUTTON_Y - - @ref GLFW_GAMEPAD_BUTTON_LEFT_BUMPER - - @ref GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER - - @ref GLFW_GAMEPAD_BUTTON_BACK - - @ref GLFW_GAMEPAD_BUTTON_START - - @ref GLFW_GAMEPAD_BUTTON_GUIDE - - @ref GLFW_GAMEPAD_BUTTON_LEFT_THUMB - - @ref GLFW_GAMEPAD_BUTTON_RIGHT_THUMB - - @ref GLFW_GAMEPAD_BUTTON_DPAD_UP - - @ref GLFW_GAMEPAD_BUTTON_DPAD_RIGHT - - @ref GLFW_GAMEPAD_BUTTON_DPAD_DOWN - - @ref GLFW_GAMEPAD_BUTTON_DPAD_LEFT - - @ref GLFW_GAMEPAD_BUTTON_LAST - - @ref GLFW_GAMEPAD_BUTTON_CROSS - - @ref GLFW_GAMEPAD_BUTTON_CIRCLE - - @ref GLFW_GAMEPAD_BUTTON_SQUARE - - @ref GLFW_GAMEPAD_BUTTON_TRIANGLE - - @ref GLFW_GAMEPAD_AXIS_LEFT_X - - @ref GLFW_GAMEPAD_AXIS_LEFT_Y - - @ref GLFW_GAMEPAD_AXIS_RIGHT_X - - @ref GLFW_GAMEPAD_AXIS_RIGHT_Y - - @ref GLFW_GAMEPAD_AXIS_LEFT_TRIGGER - - @ref GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER - - @ref GLFW_GAMEPAD_AXIS_LAST - - -@section news_32 Release notes for 3.2 - -These are the release notes for version 3.2. For a more detailed view including -all fixed bugs see the [version history](https://www.glfw.org/changelog.html). - - -@subsection features_32 New features in version 3.2 - -@subsubsection news_32_vulkan Support for Vulkan - -GLFW now supports basic integration with Vulkan with @ref glfwVulkanSupported, -@ref glfwGetRequiredInstanceExtensions, @ref glfwGetInstanceProcAddress, @ref -glfwGetPhysicalDevicePresentationSupport and @ref glfwCreateWindowSurface. -Vulkan header inclusion can be selected with -@ref GLFW_INCLUDE_VULKAN. - - -@subsubsection news_32_setwindowmonitor Window mode switching - -GLFW now supports switching between windowed and full screen modes and updating -the monitor and desired resolution and refresh rate of full screen windows with -@ref glfwSetWindowMonitor. - - -@subsubsection news_32_maximize Window maxmimization support - -GLFW now supports window maximization with @ref glfwMaximizeWindow and the -@ref GLFW_MAXIMIZED window hint and attribute. - - -@subsubsection news_32_focus Window input focus control - -GLFW now supports giving windows input focus with @ref glfwFocusWindow. - - -@subsubsection news_32_sizelimits Window size limit support - -GLFW now supports setting both absolute and relative window size limits with -@ref glfwSetWindowSizeLimits and @ref glfwSetWindowAspectRatio. - - -@subsubsection news_32_keyname Localized key names - -GLFW now supports querying the localized name of printable keys with @ref -glfwGetKeyName, either by key token or by scancode. - - -@subsubsection news_32_waittimeout Wait for events with timeout - -GLFW now supports waiting for events for a set amount of time with @ref -glfwWaitEventsTimeout. - - -@subsubsection news_32_icon Window icon support - -GLFW now supports setting the icon of windows with @ref glfwSetWindowIcon. - - -@subsubsection news_32_timer Raw timer access - -GLFW now supports raw timer values with @ref glfwGetTimerValue and @ref -glfwGetTimerFrequency. - - -@subsubsection news_32_joystick Joystick connection callback - -GLFW now supports notifying when a joystick has been connected or disconnected -with @ref glfwSetJoystickCallback. - - -@subsubsection news_32_noapi Context-less windows - -GLFW now supports creating windows without a OpenGL or OpenGL ES context by -setting the [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_NO_API`. - - -@subsubsection news_32_contextapi Run-time context creation API selection - -GLFW now supports selecting and querying the context creation API at run-time -with the @ref GLFW_CONTEXT_CREATION_API hint and attribute. - - -@subsubsection news_32_noerror Error-free context creation - -GLFW now supports creating and querying OpenGL and OpenGL ES contexts that do -not emit errors with the @ref GLFW_CONTEXT_NO_ERROR hint, provided the machine -supports the `GL_KHR_no_error` extension. - - -@subsubsection news_32_cmake CMake config-file package support - -GLFW now supports being used as a -[config-file package](@ref build_link_cmake_package) from other projects for -easy linking with the library and its dependencies. - - -@section news_31 Release notes for 3.1 - -These are the release notes for version 3.1. For a more detailed view including -all fixed bugs see the [version history](https://www.glfw.org/changelog.html). - - -@subsection features_31 New features in version 3.1 - -@subsubsection news_31_cursor Custom mouse cursor images - -GLFW now supports creating and setting both custom cursor images and standard -cursor shapes. They are created with @ref glfwCreateCursor or @ref -glfwCreateStandardCursor, set with @ref glfwSetCursor and destroyed with @ref -glfwDestroyCursor. - -@see @ref cursor_object - - -@subsubsection news_31_drop Path drop event - -GLFW now provides a callback for receiving the paths of files and directories -dropped onto GLFW windows. The callback is set with @ref glfwSetDropCallback. - -@see @ref path_drop - - -@subsubsection news_31_emptyevent Main thread wake-up - -GLFW now provides the @ref glfwPostEmptyEvent function for posting an empty -event from another thread to the main thread event queue, causing @ref -glfwWaitEvents to return. - -@see @ref events - - -@subsubsection news_31_framesize Window frame size query - -GLFW now supports querying the size, on each side, of the frame around the -content area of a window, with @ref glfwGetWindowFrameSize. - -@see [Window size](@ref window_size) - - -@subsubsection news_31_autoiconify Simultaneous multi-monitor rendering - -GLFW now supports disabling auto-iconification of full screen windows with -the [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_hint) window hint. This is -intended for people building multi-monitor installations, where you need windows -to stay in full screen despite losing input focus. - - -@subsubsection news_31_floating Floating windows - -GLFW now supports floating windows, also called topmost or always on top, for -easier debugging with the @ref GLFW_FLOATING window hint and attribute. - - -@subsubsection news_31_focused Initially unfocused windows - -GLFW now supports preventing a windowed mode window from gaining input focus on -creation, with the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) window hint. - - -@subsubsection news_31_direct Direct access for window attributes and cursor position - -GLFW now queries the window input focus, visibility and iconification attributes -and the cursor position directly instead of returning cached data. - - -@subsubsection news_31_charmods Character with modifiers callback - -GLFW now provides a callback for character events with modifier key bits. The -callback is set with @ref glfwSetCharModsCallback. Unlike the regular character -callback, this will report character events that will not result in a character -being input, for example if the Control key is held down. - -@see @ref input_char - - -@subsubsection news_31_single Single buffered framebuffers - -GLFW now supports the creation of single buffered windows, with the @ref -GLFW_DOUBLEBUFFER hint. - - -@subsubsection news_31_glext Macro for including extension header - -GLFW now includes the extension header appropriate for the chosen OpenGL or -OpenGL ES header when @ref GLFW_INCLUDE_GLEXT is defined. GLFW does not provide -these headers. They must be provided by your development environment or your -OpenGL or OpenGL ES SDK. - - -@subsubsection news_31_release Context release behaviors - -GLFW now supports controlling and querying whether the pipeline is flushed when -a context is made non-current, with the @ref GLFW_CONTEXT_RELEASE_BEHAVIOR hint -and attribute, provided the machine supports the `GL_KHR_context_flush_control` -extension. - - -@subsubsection news_31_wayland (Experimental) Wayland support - -GLFW now has an _experimental_ Wayland display protocol backend that can be -selected on Linux with a CMake option. - - -@subsubsection news_31_mir (Experimental) Mir support - -GLFW now has an _experimental_ Mir display server backend that can be selected -on Linux with a CMake option. - - -@section news_30 Release notes for 3.0 - -These are the release notes for version 3.0. For a more detailed view including -all fixed bugs see the [version history](https://www.glfw.org/changelog.html). - - -@subsection features_30 New features in version 3.0 - -@subsubsection news_30_cmake CMake build system - -GLFW now uses the CMake build system instead of the various makefiles and -project files used by earlier versions. CMake is available for all platforms -supported by GLFW, is present in most package systems and can generate -makefiles and/or project files for most popular development environments. - -For more information on how to use CMake, see the -[CMake manual](https://cmake.org/cmake/help/documentation.html). - - -@subsubsection news_30_multiwnd Multi-window support - -GLFW now supports the creation of multiple windows, each with their own OpenGL -or OpenGL ES context, and all window functions now take a window handle. Event -callbacks are now per-window and are provided with the handle of the window that -received the event. The @ref glfwMakeContextCurrent function has been added to -select which context is current on a given thread. - - -@subsubsection news_30_multimon Multi-monitor support - -GLFW now explicitly supports multiple monitors. They can be enumerated with -@ref glfwGetMonitors, queried with @ref glfwGetVideoModes, @ref -glfwGetMonitorPos, @ref glfwGetMonitorName and @ref glfwGetMonitorPhysicalSize, -and specified at window creation to make the newly created window full screen on -that specific monitor. - - -@subsubsection news_30_unicode Unicode support - -All string arguments to GLFW functions and all strings returned by GLFW now use -the UTF-8 encoding. This includes the window title, error string, clipboard -text, monitor and joystick names as well as the extension function arguments (as -ASCII is a subset of UTF-8). - - -@subsubsection news_30_clipboard Clipboard text I/O - -GLFW now supports reading and writing plain text to and from the system -clipboard, with the @ref glfwGetClipboardString and @ref glfwSetClipboardString -functions. - - -@subsubsection news_30_gamma Gamma ramp support - -GLFW now supports setting and reading back the gamma ramp of monitors, with the -@ref glfwGetGammaRamp and @ref glfwSetGammaRamp functions. There is also @ref -glfwSetGamma, which generates a ramp from a gamma value and then sets it. - - -@subsubsection news_30_gles OpenGL ES support - -GLFW now supports the creation of OpenGL ES contexts, by setting the -[GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_OPENGL_ES_API`, where -creation of such contexts are supported. Note that GLFW _does not implement_ -OpenGL ES, so your driver must provide support in a way usable by GLFW. Modern -Nvidia and Intel drivers support creation of OpenGL ES context using the GLX and -WGL APIs, while AMD provides an EGL implementation instead. - - -@subsubsection news_30_egl (Experimental) EGL support - -GLFW now has an experimental EGL context creation back end that can be selected -through CMake options. - - -@subsubsection news_30_hidpi High-DPI support - -GLFW now supports high-DPI monitors on both Windows and macOS, giving windows -full resolution framebuffers where other UI elements are scaled up. To achieve -this, @ref glfwGetFramebufferSize and @ref glfwSetFramebufferSizeCallback have -been added. These work with pixels, while the rest of the GLFW API works with -screen coordinates. This is important as OpenGL uses pixels, not screen -coordinates. - - -@subsubsection news_30_error Error callback - -GLFW now has an error callback, which can provide your application with much -more detailed diagnostics than was previously possible. The callback is passed -an error code and a description string. - - -@subsubsection news_30_wndptr Per-window user pointer - -Each window now has a user-defined pointer, retrieved with @ref -glfwGetWindowUserPointer and set with @ref glfwSetWindowUserPointer, to make it -easier to integrate GLFW into C++ code. - - -@subsubsection news_30_iconifyfun Window iconification callback - -Each window now has a callback for iconification and restoration events, -which is set with @ref glfwSetWindowIconifyCallback. - - -@subsubsection news_30_wndposfun Window position callback - -Each window now has a callback for position events, which is set with @ref -glfwSetWindowPosCallback. - - -@subsubsection news_30_wndpos Window position query - -The position of a window can now be retrieved using @ref glfwGetWindowPos. - - -@subsubsection news_30_focusfun Window focus callback - -Each windows now has a callback for focus events, which is set with @ref -glfwSetWindowFocusCallback. - - -@subsubsection news_30_enterleave Cursor enter/leave callback - -Each window now has a callback for when the mouse cursor enters or leaves its -content area, which is set with @ref glfwSetCursorEnterCallback. - - -@subsubsection news_30_wndtitle Initial window title - -The title of a window is now specified at creation time, as one of the arguments -to @ref glfwCreateWindow. - - -@subsubsection news_30_hidden Hidden windows - -Windows can now be hidden with @ref glfwHideWindow, shown using @ref -glfwShowWindow and created initially hidden with the @ref GLFW_VISIBLE window -hint and attribute. This allows for off-screen rendering in a way compatible -with most drivers, as well as moving a window to a specific position before -showing it. - - -@subsubsection news_30_undecorated Undecorated windows - -Windowed mode windows can now be created without decorations, e.g. things like -a frame, a title bar, with the @ref GLFW_DECORATED window hint and attribute. -This allows for the creation of things like splash screens. - - -@subsubsection news_30_keymods Modifier key bit masks - -[Modifier key bit mask](@ref mods) parameters have been added to the -[mouse button](@ref GLFWmousebuttonfun) and [key](@ref GLFWkeyfun) callbacks. - - -@subsubsection news_30_scancode Platform-specific scancodes - -A scancode parameter has been added to the [key callback](@ref GLFWkeyfun). Keys -that don't have a [key token](@ref keys) still get passed on with the key -parameter set to `GLFW_KEY_UNKNOWN`. These scancodes will vary between machines -and are intended to be used for key bindings. - - -@subsubsection news_30_jsname Joystick names - -The name of a joystick can now be retrieved using @ref glfwGetJoystickName. - - -@subsubsection news_30_doxygen Doxygen documentation - -You are reading it. +- [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) */ From 82978bb3affbd472060d2e64e1f7be1dd774d2f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 18 Oct 2019 13:21:59 +0200 Subject: [PATCH 24/56] Documentation work This is the documentation update for the change introduced with 0b01d850ed00abf65ede29da46ad28ca5dbf8081, removing the requirement for the forward-compatibility flag on macOS. --- docs/compat.dox | 3 +-- docs/window.dox | 10 ++++------ include/GLFW/glfw3.h | 11 +++++------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/docs/compat.dox b/docs/compat.dox index 25bfc1aa..77ba63b4 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -230,8 +230,7 @@ at most OpenGL version 2.1. 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_FORWARD_COMPAT` hint must be set to -`GLFW_TRUE` and the `GLFW_OPENGL_PROFILE` hint must be set to +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_OPENGL_DEBUG_CONTEXT` and `GLFW_CONTEXT_NO_ERROR` hints are ignored. diff --git a/docs/window.dox b/docs/window.dox index 3a9e4a29..16276a65 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -383,12 +383,10 @@ Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested, and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0, but OpenGL ES 2.0 is not backward compatible with 1.x. -@note @macos The OS only supports forward-compatible core profile contexts for -OpenGL versions 3.2 and later. Before creating an OpenGL context of version -3.2 or later you must set the -[GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and -[GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly. OpenGL -3.0 and 3.1 contexts are not supported at all on macOS. +@note @macos The OS only supports core profile contexts for OpenGL versions 3.2 +and later. Before creating an OpenGL context of version 3.2 or later you must +set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hint accordingly. +OpenGL 3.0 and 3.1 contexts are not supported at all on macOS. @anchor GLFW_OPENGL_FORWARD_COMPAT_hint __GLFW_OPENGL_FORWARD_COMPAT__ specifies whether the OpenGL context should be diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index dad45a49..2aade0f0 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -2580,12 +2580,11 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value); * @remark @win32 The context to share resources with must not be current on * any other thread. * - * @remark @macos The OS only supports forward-compatible core profile contexts - * for OpenGL versions 3.2 and later. Before creating an OpenGL context of - * version 3.2 or later you must set the - * [GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and - * [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly. - * OpenGL 3.0 and 3.1 contexts are not supported at all on macOS. + * @remark @macos The OS only supports core profile contexts for OpenGL + * versions 3.2 and later. Before creating an OpenGL context of version 3.2 or + * later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) + * hint accordingly. OpenGL 3.0 and 3.1 contexts are not supported at all + * on macOS. * * @remark @macos The GLFW window has no icon, as it is not a document * window, but the dock icon will be the same as the application bundle's icon. From 4d0ae4ffa74f71f91a807a08e9f09324862f1ffc Mon Sep 17 00:00:00 2001 From: Pablo Prietz Date: Thu, 24 Oct 2019 12:04:18 +0200 Subject: [PATCH 25/56] Fix CMake 3.0 - 3.6 support regression Replaces `VERSION_GREATER_EQUAL` with `VERSION_EQUAL OR VERSION_GREATER`. `VERSION_GREATER_EQUAL` was only added in CMake 3.7. Fixes #1584. Closes #1585. --- README.md | 1 + src/CMakeLists.txt | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ac0f645..01f99df4 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,7 @@ skills. - Santi Zupancic - Jonas Ådahl - Lasse Öörni + - Pablo Prietz - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0af6dd05..c7364902 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,7 +100,10 @@ set_target_properties(glfw PROPERTIES POSITION_INDEPENDENT_CODE ON FOLDER "GLFW3") -if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.1.0") +if ( + ${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR + ${CMAKE_VERSION} VERSION_GREATER "3.1.0" +) set_target_properties(glfw PROPERTIES C_STANDARD 99) else() # Remove this fallback when removing support for CMake version less than 3.1 From 04f7f55f077bcb61081d8249ac0515b1453eedfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Oct 2019 16:20:43 +0200 Subject: [PATCH 26/56] Cleanup Related to #1585. --- README.md | 2 +- src/CMakeLists.txt | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 01f99df4..1d209ba8 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,7 @@ skills. - Konstantin Podsvirov - Nathan Poirier - Alexandre Pretyman + - Pablo Prietz - przemekmirek - Guillaume Racicot - Philip Rideout @@ -339,7 +340,6 @@ skills. - Santi Zupancic - Jonas Ådahl - Lasse Öörni - - Pablo Prietz - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7364902..b78b8d37 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,10 +100,9 @@ set_target_properties(glfw PROPERTIES POSITION_INDEPENDENT_CODE ON FOLDER "GLFW3") -if ( - ${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR - ${CMAKE_VERSION} VERSION_GREATER "3.1.0" -) +if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR + ${CMAKE_VERSION} VERSION_GREATER "3.1.0") + set_target_properties(glfw PROPERTIES C_STANDARD 99) else() # Remove this fallback when removing support for CMake version less than 3.1 From 33683ec60e96dd52e99c48b7e7c1dad664d234ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 24 Oct 2019 16:27:26 +0200 Subject: [PATCH 27/56] Remove stray characters from hardcoded CFLAGS The additional '>' characters were appended to the compiler option. Related to #1576. --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b78b8d37..6cbeed6d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -108,8 +108,8 @@ else() # Remove this fallback when removing support for CMake version less than 3.1 target_compile_options(glfw PRIVATE "$<$:-std=c99>" - "$<$:-std=c99>>" - "$<$:-std=c99>>") + "$<$:-std=c99>" + "$<$:-std=c99>") endif() target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) From 5fc4c01302b0729fd9f39e8c504e28cf7347153c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Sep 2019 18:29:37 +0200 Subject: [PATCH 28/56] X11: Fix decoration enabling after window creation This fixes the enabling of window decorations after creation. Instead of removing the _MOTIF_WM_HINTS property, we now set or unset the MWM_DECOR_ALL bit of the decorations field. Fixes #1566. --- README.md | 1 + src/x11_window.c | 43 +++++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1d209ba8..068a8f66 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ information on what to include when reporting a bug. - [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) - [NSGL] Removed enforcement of forward-compatible flag for core contexts diff --git a/src/x11_window.c b/src/x11_window.c index d8355ae8..56379a3c 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -50,6 +50,10 @@ #define Button6 6 #define Button7 7 +// Motif WM hints flags +#define MWM_HINTS_DECORATIONS 2 +#define MWM_DECOR_ALL 1 + #define _GLFW_XDND_VERSION 5 @@ -2536,33 +2540,24 @@ void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) { - if (enabled) + struct { - XDeleteProperty(_glfw.x11.display, - window->x11.handle, - _glfw.x11.MOTIF_WM_HINTS); - } - else - { - struct - { - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long input_mode; - unsigned long status; - } hints; + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; + } hints = {0}; - hints.flags = 2; // Set decorations - hints.decorations = 0; // No decorations + hints.flags = MWM_HINTS_DECORATIONS; + hints.decorations = enabled ? MWM_DECOR_ALL : 0; - XChangeProperty(_glfw.x11.display, window->x11.handle, - _glfw.x11.MOTIF_WM_HINTS, - _glfw.x11.MOTIF_WM_HINTS, 32, - PropModeReplace, - (unsigned char*) &hints, - sizeof(hints) / sizeof(long)); - } + XChangeProperty(_glfw.x11.display, window->x11.handle, + _glfw.x11.MOTIF_WM_HINTS, + _glfw.x11.MOTIF_WM_HINTS, 32, + PropModeReplace, + (unsigned char*) &hints, + sizeof(hints) / sizeof(long)); } void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) From 75294462b354d147aa5914c30e3005551cc04e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 28 Oct 2019 19:18:19 +0100 Subject: [PATCH 29/56] X11: Fix content scale fallback value on KDE KDE sometimes removes the Xft.dpi resource when it would be set to the X11 default value of 96, causing GLFW to fall back to a value calculated from the core display sizes in pixels and mm in a desktop environment that supports Xft.dpi. This moves to a hardcoded fallback value of 96 on the assumption that there are more people running KDE with 96 DPI than there are people running desktop environments that do not support Xft.dpi. All of this is terrible please send help. Fixes #1578. --- README.md | 1 + src/x11_init.c | 11 ++++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 068a8f66..9b9ef7db 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ information on what to include when reporting a bug. - [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) - [NSGL] Removed enforcement of forward-compatible flag for core contexts diff --git a/src/x11_init.c b/src/x11_init.c index ae76d36b..ca8b2ff2 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -793,13 +793,10 @@ static GLFWbool initExtensions(void) // static void getSystemContentScale(float* xscale, float* yscale) { - // NOTE: Fall back to the display-wide DPI instead of RandR monitor DPI if - // Xft.dpi retrieval below fails as we don't currently have an exact - // policy for which monitor a window is considered to "be on" - float xdpi = DisplayWidth(_glfw.x11.display, _glfw.x11.screen) * - 25.4f / DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen); - float ydpi = DisplayHeight(_glfw.x11.display, _glfw.x11.screen) * - 25.4f / DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen); + // Start by assuming the default X11 DPI + // NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it + // would be set to 96, so assume that is the case if we cannot find it + float xdpi = 96.f, ydpi = 96.f; // NOTE: Basing the scale on Xft.dpi where available should provide the most // consistent user experience (matches Qt, Gtk, etc), although not From 28d850770022afc8b73d88a871fa07e8d35766b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 1 Nov 2019 13:27:44 +0100 Subject: [PATCH 30/56] Fix order of words in window guide Fixes #1571. --- docs/window.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/window.dox b/docs/window.dox index 16276a65..705570d6 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -1398,7 +1398,7 @@ glfwSwapBuffers(window); Sometimes it can be useful to select when the buffer swap will occur. With the function @ref glfwSwapInterval it is possible to select the minimum number of -monitor refreshes the driver wait should from the time @ref glfwSwapBuffers was +monitor refreshes the driver should wait from the time @ref glfwSwapBuffers was called before swapping the buffers: @code From c88ee1c9d3e018c199eaf0b0f5ccc3874ac1de09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Nov 2019 18:55:42 +0100 Subject: [PATCH 31/56] Win32: Change transparent framebuffer key color This is a temporary fix while we determine if the color key workaround should be removed completely. See issue thread for discussion. Related to #1512. --- docs/window.dox | 7 +++++++ src/win32_window.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/window.dox b/docs/window.dox index 705570d6..4c4ab026 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -234,6 +234,13 @@ alpha channel will be used to combine the framebuffer with the background. This does not affect window decorations. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. +@par +@win32 GLFW sets a color key for the window to work around repainting issues +with a transparent framebuffer. The chosen color value is RGB 255,0,255 +(magenta). This will make pixels with that exact color fully transparent +regardless of their alpha values. If this is a problem, make these pixels any +other color before buffer swap. + @anchor GLFW_FOCUS_ON_SHOW_hint __GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. diff --git a/src/win32_window.c b/src/win32_window.c index efb4e043..455c4e2e 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -411,7 +411,7 @@ static void updateFramebufferTransparency(const _GLFWwindow* window) // issue. When set to black, something is making the hit test // not resize with the window frame. SetLayeredWindowAttributes(window->win32.handle, - RGB(0, 193, 48), 255, LWA_COLORKEY); + RGB(255, 0, 255), 255, LWA_COLORKEY); } DeleteObject(region); From b69fb99031258f5fe37281ce4a6e44ce96e32a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Nov 2019 20:37:08 +0100 Subject: [PATCH 32/56] Remove mappings for GUID used by different devices The SDL2 2.0.5+ controller GUID 03000000790000000600000000000000 matches many devices with different layouts and element counts but with the same chipset. This issue is still being resolved upstream. In the meantime this removes those mappings from GLFW to avoid confusion and errors. SDL upstream issue: https://bugzilla.libsdl.org/show_bug.cgi?id=4545 Related to #1583. --- src/mappings.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mappings.h b/src/mappings.h index ef76c90f..eda9a549 100644 --- a/src/mappings.h +++ b/src/mappings.h @@ -84,7 +84,6 @@ const char* _glfwDefaultMappings[] = "030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,", "030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,", "78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,", -"03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,", "03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,", "030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,", "03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,", @@ -207,7 +206,6 @@ const char* _glfwDefaultMappings[] = "030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,", "03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,", "03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,", -"03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Mac OS X,", "03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,", "030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,", From c5f1ca3e410e1f719c4e02c70c7827729cb7c888 Mon Sep 17 00:00:00 2001 From: thewoz Date: Tue, 5 Nov 2019 16:27:06 +0100 Subject: [PATCH 33/56] Add canonical build directory to .gitignore Closes #1595. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 96d5ba3f..c5c2994b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ Release MinSizeRel RelWithDebInfo *.xcodeproj +build # CMake files Makefile From 20e522cdf4b6b772e3609e95eb9773c29ed9fee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Sep 2019 19:22:36 +0200 Subject: [PATCH 34/56] Make events test output only UTF-8 in C locale --- tests/events.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/tests/events.c b/tests/events.c index 251e15d9..f29dfbb0 100644 --- a/tests/events.c +++ b/tests/events.c @@ -253,17 +253,32 @@ static const char* get_mods_name(int mods) return name; } -static const char* get_character_string(int codepoint) +static size_t encode_utf8(char* s, unsigned int ch) { - // This assumes UTF-8, which is stupid - static char result[6 + 1]; + size_t count = 0; - int length = wctomb(result, codepoint); - if (length == -1) - length = 0; + if (ch < 0x80) + s[count++] = (char) ch; + else if (ch < 0x800) + { + s[count++] = (ch >> 6) | 0xc0; + s[count++] = (ch & 0x3f) | 0x80; + } + else if (ch < 0x10000) + { + s[count++] = (ch >> 12) | 0xe0; + s[count++] = ((ch >> 6) & 0x3f) | 0x80; + s[count++] = (ch & 0x3f) | 0x80; + } + else if (ch < 0x110000) + { + s[count++] = (ch >> 18) | 0xf0; + s[count++] = ((ch >> 12) & 0x3f) | 0x80; + s[count++] = ((ch >> 6) & 0x3f) | 0x80; + s[count++] = (ch & 0x3f) | 0x80; + } - result[length] = '\0'; - return result; + return count; } static void error_callback(int error, const char* description) @@ -425,9 +440,11 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, static void char_callback(GLFWwindow* window, unsigned int codepoint) { Slot* slot = glfwGetWindowUserPointer(window); + char string[5] = ""; + + encode_utf8(string, codepoint); printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n", - counter++, slot->number, glfwGetTime(), codepoint, - get_character_string(codepoint)); + counter++, slot->number, glfwGetTime(), codepoint, string); } static void drop_callback(GLFWwindow* window, int count, const char* paths[]) @@ -500,8 +517,6 @@ int main(int argc, char** argv) GLFWmonitor* monitor = NULL; int ch, i, width, height, count = 1; - setlocale(LC_ALL, ""); - glfwSetErrorCallback(error_callback); if (!glfwInit()) From 08f01c31a0b856bf5ba6b8cbce898e94ad736a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Sep 2019 19:27:09 +0200 Subject: [PATCH 35/56] Add gamepad information to events test output --- tests/events.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/events.c b/tests/events.c index f29dfbb0..1eecc4c2 100644 --- a/tests/events.c +++ b/tests/events.c @@ -503,6 +503,20 @@ static void joystick_callback(int jid, int event) axisCount, buttonCount, hatCount); + + if (glfwJoystickIsGamepad(jid)) + { + printf(" Joystick %i (%s) has a gamepad mapping (%s)\n", + jid, + glfwGetJoystickGUID(jid), + glfwGetGamepadName(jid)); + } + else + { + printf(" Joystick %i (%s) has no gamepad mapping\n", + jid, + glfwGetJoystickGUID(jid)); + } } else { From de2342945570862cde9d4ab1b3daeebc48b6d379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 26 Sep 2019 23:31:22 +0200 Subject: [PATCH 36/56] Add reminder for why events test is not closing --- tests/events.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/events.c b/tests/events.c index 1eecc4c2..86a63df2 100644 --- a/tests/events.c +++ b/tests/events.c @@ -320,6 +320,12 @@ static void window_close_callback(GLFWwindow* window) printf("%08x to %i at %0.3f: Window close\n", counter++, slot->number, glfwGetTime()); + if (!slot->closeable) + { + printf("(( closing is disabled, press %s to re-enable )\n", + glfwGetKeyName(GLFW_KEY_C, 0)); + } + glfwSetWindowShouldClose(window, slot->closeable); } From 8e288dc94cbad84454173c137ae17d956d0b6364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Aug 2019 19:00:59 +0200 Subject: [PATCH 37/56] Win32: Add GLFW_WIN32_KEYBOARD_MENU This platform specific window hint enables access to the Windows window menu via the keyboard shortcuts. --- README.md | 2 ++ docs/news.dox | 11 +++++++++++ docs/window.dox | 9 +++++++++ include/GLFW/glfw3.h | 1 + src/internal.h | 3 +++ src/win32_platform.h | 1 + src/win32_window.c | 12 +++++++++++- src/window.c | 3 +++ tests/gamma.c | 1 + tests/inputlag.c | 1 + tests/joysticks.c | 1 + tests/opacity.c | 1 + 12 files changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b9ef7db..744cc751 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,8 @@ information on what to include when reporting a bug. relocatable (#1470) - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) - Bugfix: Compiling with -Wextra-semi caused warnings (#1440) + - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access + to the window menu - [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 diff --git a/docs/news.dox b/docs/news.dox index e3063c63..39f19031 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -9,6 +9,15 @@ @subsection features_34 New features in version 3.4 +@subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu + +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. + + @subsection caveats_34 Caveats for version 3.4 @subsubsection standalone_34 Tests and examples are disabled when built as a sub-project @@ -35,6 +44,8 @@ add_subdirectory(path/to/glfw) @subsubsection types_34 New types in version 3.4 @subsubsection constants_34 New constants in version 3.4 + - @ref GLFW_WIN32_KEYBOARD_MENU + @section news_archive Release notes for earlier versions diff --git a/docs/window.dox b/docs/window.dox index 4c4ab026..868c6c21 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -455,6 +455,14 @@ The no error mode for OpenGL and OpenGL ES is described in detail by the extension. +@subsubsection window_hints_win32 Windows specific window hints + +@anchor GLFW_WIN32_KEYBOARD_MENU_hint +__GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window +menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts. This is +ignored on other platforms. + + @subsubsection window_hints_osx macOS specific window hints @anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint @@ -535,6 +543,7 @@ GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_ GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE` +GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded frame autosave name GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 2aade0f0..0b603160 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1003,6 +1003,7 @@ extern "C" { * [window hint](@ref GLFW_X11_CLASS_NAME_hint). */ #define GLFW_X11_INSTANCE_NAME 0x00024002 +#define GLFW_WIN32_KEYBOARD_MENU 0x00025001 /*! @} */ #define GLFW_NO_API 0 diff --git a/src/internal.h b/src/internal.h index acdae22d..4c75c9b1 100644 --- a/src/internal.h +++ b/src/internal.h @@ -274,6 +274,9 @@ struct _GLFWwndconfig char className[256]; char instanceName[256]; } x11; + struct { + GLFWbool keymenu; + } win32; }; // Context configuration diff --git a/src/win32_platform.h b/src/win32_platform.h index 6507c872..2b00b001 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -315,6 +315,7 @@ typedef struct _GLFWwindowWin32 // Whether to enable framebuffer transparency on DWM GLFWbool transparent; GLFWbool scaleToMonitor; + GLFWbool keymenu; // The last received cursor position, regardless of source int lastCursorPosX, lastCursorPosY; diff --git a/src/win32_window.c b/src/win32_window.c index 455c4e2e..81cdf62a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -699,7 +699,12 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // User trying to access application menu using ALT? case SC_KEYMENU: - return 0; + { + if (!window->win32.keymenu) + return 0; + + break; + } } break; } @@ -731,6 +736,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, } _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain); + + if (uMsg == WM_SYSCHAR && window->win32.keymenu) + break; + return 0; } @@ -1275,6 +1284,7 @@ static int createNativeWindow(_GLFWwindow* window, } window->win32.scaleToMonitor = wndconfig->scaleToMonitor; + window->win32.keymenu = wndconfig->win32.keymenu; // Adjust window rect to account for DPI scaling of the window frame and // (if enabled) DPI scaling of the content area diff --git a/src/window.c b/src/window.c index fa604d01..bb5ba956 100644 --- a/src/window.c +++ b/src/window.c @@ -363,6 +363,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_COCOA_RETINA_FRAMEBUFFER: _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE; return; + case GLFW_WIN32_KEYBOARD_MENU: + _glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE; + return; case GLFW_COCOA_GRAPHICS_SWITCHING: _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; return; diff --git a/tests/gamma.c b/tests/gamma.c index aa4c8b78..d1961609 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -101,6 +101,7 @@ int main(int argc, char** argv) monitor = glfwGetPrimaryMonitor(); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(800, 400, "Gamma Test", NULL, NULL); if (!window) diff --git a/tests/inputlag.c b/tests/inputlag.c index 269a0c8f..2ed4c49f 100644 --- a/tests/inputlag.c +++ b/tests/inputlag.c @@ -202,6 +202,7 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(width, height, "Input lag test", monitor, NULL); if (!window) diff --git a/tests/joysticks.c b/tests/joysticks.c index 8eae021e..d4aef36f 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -182,6 +182,7 @@ int main(void) exit(EXIT_FAILURE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(800, 600, "Joystick Test", NULL, NULL); if (!window) diff --git a/tests/opacity.c b/tests/opacity.c index 47f28b16..e1da9ef1 100644 --- a/tests/opacity.c +++ b/tests/opacity.c @@ -59,6 +59,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL); if (!window) From bc5523e994ff79304b2a690b354b7531dbbe1246 Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Sun, 3 Nov 2019 21:12:01 -0500 Subject: [PATCH 38/56] Set C standard at 99 for all test targets Related to #1593. --- tests/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fcc99243..4f49c770 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,6 +20,18 @@ set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" "${GLFW_SOURCE_DIR}/deps/tinycthread.c") +if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR + ${CMAKE_VERSION} VERSION_GREATER "3.1.0") + set(CMAKE_C_STANDARD 99) +else() + # Remove this fallback when removing support for CMake version less than 3.1 + add_compile_options( + "$<$:-std=c99>" + "$<$:-std=c99>" + "$<$:-std=c99>") + +endif() + add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL}) add_executable(events events.c ${GETOPT} ${GLAD_GL}) add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL}) From 70a3104c4977fc4ea55efb12d4c565b2581edd5c Mon Sep 17 00:00:00 2001 From: Guillaume Racicot Date: Sat, 9 Nov 2019 12:19:49 -0500 Subject: [PATCH 39/56] Set C standard at 99 for all example targets Closes #1593. --- examples/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 93b30ed2..7203a925 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,6 +23,18 @@ elseif (APPLE) MACOSX_PACKAGE_LOCATION "Resources") endif() +if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR + ${CMAKE_VERSION} VERSION_GREATER "3.1.0") + set(CMAKE_C_STANDARD 99) +else() + # Remove this fallback when removing support for CMake version less than 3.1 + add_compile_options( + "$<$:-std=c99>" + "$<$:-std=c99>" + "$<$:-std=c99>") + +endif() + set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h" "${GLFW_SOURCE_DIR}/deps/glad_gl.c") set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" From 953a1c3f8b793dcb23879ca1032b7b62f0f27410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 10 Nov 2019 15:20:29 +0100 Subject: [PATCH 40/56] Cleanup --- examples/CMakeLists.txt | 3 +-- tests/CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7203a925..597c1e13 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,8 +28,7 @@ if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR set(CMAKE_C_STANDARD 99) else() # Remove this fallback when removing support for CMake version less than 3.1 - add_compile_options( - "$<$:-std=c99>" + add_compile_options("$<$:-std=c99>" "$<$:-std=c99>" "$<$:-std=c99>") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4f49c770..c471d8b9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -25,8 +25,7 @@ if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR set(CMAKE_C_STANDARD 99) else() # Remove this fallback when removing support for CMake version less than 3.1 - add_compile_options( - "$<$:-std=c99>" + add_compile_options("$<$:-std=c99>" "$<$:-std=c99>" "$<$:-std=c99>") From 94cb0347abdc4e8ebf8dcf133894a764d395b84c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Nov 2019 17:25:16 +0100 Subject: [PATCH 41/56] Cocoa: Add comments for Cocoa symbol macros --- src/cocoa_platform.h | 3 +++ src/nsgl_context.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index f8bfe3e6..21d83bcc 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -41,6 +41,9 @@ typedef void* id; #endif +// NOTE: Many Cocoa enum values have been renamed and we need to build across +// SDK versions where one is unavailable or the other deprecated +// We use the newer names in code and these macros to handle compatibility #if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat #define NSEventMaskAny NSAnyEventMask diff --git a/src/nsgl_context.h b/src/nsgl_context.h index 2c8eb23f..edd958e1 100644 --- a/src/nsgl_context.h +++ b/src/nsgl_context.h @@ -24,6 +24,9 @@ // //======================================================================== +// NOTE: Many Cocoa enum values have been renamed and we need to build across +// SDK versions where one is unavailable or the other deprecated +// We use the newer names in code and these macros to handle compatibility #if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity From c819f27ce3e6639b4d4b432c0e5191e5c26a9d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Nov 2019 23:34:08 +0100 Subject: [PATCH 42/56] Cocoa: Process events after window destruction On macOS a destroyed window remained on screen until the next time events were processed. This makes the behavior more consistent with other platforms. Fixes #1412. --- README.md | 2 ++ src/cocoa_window.m | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 744cc751..ad41c133 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the window (#1499) - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) + - [Cocoa] Bugfix: Window remained on screen after destruction until event poll + (#1412) - [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) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index dd8879b5..887bfd6f 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -962,6 +962,9 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) [window->ns.object close]; window->ns.object = nil; + // HACK: Allow Cocoa to catch up before returning + _glfwPlatformPollEvents(); + } // autoreleasepool } From bac15f94493938eded7161a7a0ab8827584e3db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 6 Nov 2019 23:46:05 +0100 Subject: [PATCH 43/56] Cocoa: Fix multiple methods warning This fixes a warning due to us using bare ids and NSCollectionLayoutAnchor having a message with the same name. --- src/cocoa_window.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 887bfd6f..b71734ea 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -816,7 +816,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window, [window->ns.object setLevel:NSMainMenuWindowLevel + 1]; else { - [window->ns.object center]; + [(NSWindow*) window->ns.object center]; _glfw.ns.cascadePoint = NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint: NSPointFromCGPoint(_glfw.ns.cascadePoint)]); From bd452016be99e10d7fa8282cd75b1c53e0d5a8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 7 Nov 2019 13:45:15 +0100 Subject: [PATCH 44/56] Cocoa: Cleanup Readability fix, does not affect generated code. --- src/nsgl_context.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 14253988..e455d412 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -332,7 +332,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window, return GLFW_FALSE; } - NSOpenGLContext* share = NULL; + NSOpenGLContext* share = nil; if (ctxconfig->share) share = ctxconfig->share->context.nsgl.object; @@ -405,7 +405,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle) if (window->context.client == GLFW_NO_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); - return NULL; + return nil; } return window->context.nsgl.object; From 2c519709be0dacc7af2908982a7ab80b889a8126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 12 Nov 2019 18:23:04 +0100 Subject: [PATCH 45/56] Cocoa: Fix full screen window iconification Iconification (miniaturization) of undecorated windows stopped working unless the window has the NSWindowStyleMaskMiniaturizable style. --- src/cocoa_window.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index b71734ea..8e0b28aa 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -35,15 +35,14 @@ // static NSUInteger getStyleMask(_GLFWwindow* window) { - NSUInteger styleMask = 0; + NSUInteger styleMask = NSWindowStyleMaskMiniaturizable; if (window->monitor || !window->decorated) styleMask |= NSWindowStyleMaskBorderless; else { styleMask |= NSWindowStyleMaskTitled | - NSWindowStyleMaskClosable | - NSWindowStyleMaskMiniaturizable; + NSWindowStyleMaskClosable; if (window->resizable) styleMask |= NSWindowStyleMaskResizable; From e96dc5d2199032d565b55c4177820ab28b1d67c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 5 Nov 2019 13:09:01 +0100 Subject: [PATCH 46/56] X11: Assume 96 DPI if RandR monitor size is zero This falls back to calculating the monitor physical size from the current resolution and the default X11 DPI when the physical size returned by RandR is zero. --- src/x11_monitor.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/x11_monitor.c b/src/x11_monitor.c index 0c649580..4d3e1a94 100644 --- a/src/x11_monitor.c +++ b/src/x11_monitor.c @@ -161,6 +161,16 @@ void _glfwPollMonitorsX11(void) heightMM = oi->mm_height; } + if (widthMM <= 0 || heightMM <= 0) + { + // HACK: If RandR does not provide a physical size, assume the + // X11 default 96 DPI and calcuate from the CRTC viewport + // NOTE: These members are affected by rotation, unlike the mode + // info and output info members + widthMM = (int) (ci->width * 25.4f / 96.f); + heightMM = (int) (ci->height * 25.4f / 96.f); + } + _GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM); monitor->x11.output = sr->outputs[i]; monitor->x11.crtc = oi->crtc; From 359758bb53400b589e311c7d4f8732a58a40a1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 13 Nov 2019 15:55:09 +0100 Subject: [PATCH 47/56] Add initial .mailmap file --- .mailmap | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .mailmap diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000..96d8a9b7 --- /dev/null +++ b/.mailmap @@ -0,0 +1,10 @@ +Camilla Löwy +Camilla Löwy +Camilla Löwy + +Emmanuel Gil Peyrot + +Marcus Geelnard +Marcus Geelnard +Marcus Geelnard + From b804379463b6378e5f38803ef29ddf74adc98a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 14:12:43 +0100 Subject: [PATCH 48/56] Add initial GH support file --- docs/SUPPORT.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docs/SUPPORT.md diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md new file mode 100644 index 00000000..604957d0 --- /dev/null +++ b/docs/SUPPORT.md @@ -0,0 +1,14 @@ +# Support resources + +See the [latest documentation](http://www.glfw.org/docs/latest/) for tutorials, +guides and the API reference. + +If you have questions about using GLFW, we have a +[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on +[Freenode](http://freenode.net/). + +Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues). +Please check the [contribution +guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for +information on what to include when reporting a bug. + From 50a6270e55e6d12a24031395943495120efd2d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 19:02:29 +0100 Subject: [PATCH 49/56] Add initial CODEOWNERS file --- docs/CODEOWNERS | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/CODEOWNERS diff --git a/docs/CODEOWNERS b/docs/CODEOWNERS new file mode 100644 index 00000000..ec174185 --- /dev/null +++ b/docs/CODEOWNERS @@ -0,0 +1,10 @@ + +* @elmindreda + +src/wl_* @linkmauve + +docs/*.css @glfw/webdev +docs/*.less @glfw/webdev +docs/*.html @glfw/webdev +docs/*.xml @glfw/webdev + From c42d8f3e5b7203a5ebb8dd7876c87b9ca282cbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 19:20:10 +0100 Subject: [PATCH 50/56] Cleanup .gitignore file somewhat --- .gitignore | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c5c2994b..2d377cf7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -# External junk -.DS_Store +# The canonical out-of-tree build subdirectory +build + +# Visual Studio clutter _ReSharper* -*.opensdf *.sdf *.suo *.dir @@ -15,10 +16,15 @@ Release MinSizeRel RelWithDebInfo *.xcodeproj -build +*.opensdf -# CMake files +# macOS clutter +.DS_Store + +# Makefile generator clutter Makefile + +# CMake clutter CMakeCache.txt CMakeFiles CMakeScripts From d861d7bffe391815bce26073c38f6f8075e46410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 19:45:29 +0100 Subject: [PATCH 51/56] Update .gitignore file This adds missing entries for Ninja and the unavoidable clutter of the modern Doxygen CMake module. --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 2d377cf7..2f580b8a 100644 --- a/.gitignore +++ b/.gitignore @@ -24,10 +24,18 @@ RelWithDebInfo # Makefile generator clutter Makefile +# Ninja generator clutter +build.ninja +rules.ninja +.ninja_deps +.ninja_log + # CMake clutter CMakeCache.txt CMakeFiles CMakeScripts +CMakeDoxyfile.in +CMakeDoxygenDefaults.cmake cmake_install.cmake cmake_uninstall.cmake From b5d4f24f7433bcdca17be72a78ce9b8cf6b64856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 14 Nov 2019 19:57:08 +0100 Subject: [PATCH 52/56] Move CMake uninstall template file to CMake subdir --- cmake_uninstall.cmake.in => CMake/cmake_uninstall.cmake.in | 6 +++--- CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename cmake_uninstall.cmake.in => CMake/cmake_uninstall.cmake.in (78%) diff --git a/cmake_uninstall.cmake.in b/CMake/cmake_uninstall.cmake.in similarity index 78% rename from cmake_uninstall.cmake.in rename to CMake/cmake_uninstall.cmake.in index 4ea57b1c..5ecc476d 100644 --- a/cmake_uninstall.cmake.in +++ b/CMake/cmake_uninstall.cmake.in @@ -1,9 +1,9 @@ -if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") +if (NOT EXISTS "@GLFW_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: \"@GLFW_BINARY_DIR@/install_manifest.txt\"") endif() -file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +file(READ "@GLFW_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") foreach (file ${files}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04174cd1..3c7ac819 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -367,7 +367,7 @@ if (GLFW_INSTALL) # Only generate this target if no higher-level project already has if (NOT TARGET uninstall) - configure_file(cmake_uninstall.cmake.in + configure_file(CMake/cmake_uninstall.cmake.in cmake_uninstall.cmake IMMEDIATE @ONLY) add_custom_target(uninstall From a9f674e719cd663560418de2a7fa1147ce6c6c9b Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Fri, 15 Nov 2019 15:30:41 +0100 Subject: [PATCH 53/56] =?UTF-8?q?Wayland:=20Don=E2=80=99t=20reload=20the?= =?UTF-8?q?=20cursor=20on=20every=20pointer=20motion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, any pointer motion in the window decorations when using the fallback implementation would obtain the wl_cursor again, and do the attach danse for no benefit. This will ultimately allow animated cursors to not reset to the first frame on motion, once these will be implemented. --- src/wl_init.c | 6 ++++-- src/wl_platform.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index cdbfcf1e..40643766 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -169,6 +169,7 @@ static void setCursor(_GLFWwindow* window, const char* name) wl_surface_damage(surface, 0, 0, image->width, image->height); wl_surface_commit(surface); + _glfw.wl.cursorPreviousName = name; } static void pointerHandleMotion(void* data, @@ -178,7 +179,7 @@ static void pointerHandleMotion(void* data, wl_fixed_t sy) { _GLFWwindow* window = _glfw.wl.pointerFocus; - const char* cursorName; + const char* cursorName = NULL; if (!window) return; @@ -227,7 +228,8 @@ static void pointerHandleMotion(void* data, default: assert(0); } - setCursor(window, cursorName); + if (_glfw.wl.cursorPreviousName != cursorName) + setCursor(window, cursorName); } static void pointerHandleButton(void* data, diff --git a/src/wl_platform.h b/src/wl_platform.h index 894a4e68..542cc78d 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -247,6 +247,7 @@ typedef struct _GLFWlibraryWayland struct wl_cursor_theme* cursorTheme; struct wl_cursor_theme* cursorThemeHiDPI; struct wl_surface* cursorSurface; + const char* cursorPreviousName; int cursorTimerfd; uint32_t serial; From a80788c17f3376177b45d52f983d4d98f1175af2 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 21 Nov 2019 13:46:18 +0100 Subject: [PATCH 54/56] =?UTF-8?q?Wayland:=20Don=E2=80=99t=20update=20curso?= =?UTF-8?q?r=20position=20in=20the=20frame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That way the application only sees the cursor moving when it is inside of its area, it won’t go back to the top or left side when trying to resize the window or just hovering the fallback decorations. --- src/wl_init.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 40643766..9e692f0e 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -180,47 +180,45 @@ static void pointerHandleMotion(void* data, { _GLFWwindow* window = _glfw.wl.pointerFocus; const char* cursorName = NULL; + double x, y; if (!window) return; if (window->cursorMode == GLFW_CURSOR_DISABLED) return; - else - { - window->wl.cursorPosX = wl_fixed_to_double(sx); - window->wl.cursorPosY = wl_fixed_to_double(sy); - } + x = wl_fixed_to_double(sx); + y = wl_fixed_to_double(sy); switch (window->wl.decorations.focus) { case mainWindow: - _glfwInputCursorPos(window, - wl_fixed_to_double(sx), - wl_fixed_to_double(sy)); + window->wl.cursorPosX = x; + window->wl.cursorPosY = y; + _glfwInputCursorPos(window, x, y); return; case topDecoration: - if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) + if (y < _GLFW_DECORATION_WIDTH) cursorName = "n-resize"; else cursorName = "left_ptr"; break; case leftDecoration: - if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) + if (y < _GLFW_DECORATION_WIDTH) cursorName = "nw-resize"; else cursorName = "w-resize"; break; case rightDecoration: - if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) + if (y < _GLFW_DECORATION_WIDTH) cursorName = "ne-resize"; else cursorName = "e-resize"; break; case bottomDecoration: - if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH) + if (x < _GLFW_DECORATION_WIDTH) cursorName = "sw-resize"; - else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH) + else if (x > window->wl.width + _GLFW_DECORATION_WIDTH) cursorName = "se-resize"; else cursorName = "s-resize"; From 80fde12fdade85a39c5c1300d0a29200691fdc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 17 May 2019 18:30:02 +0200 Subject: [PATCH 55/56] Wayland: Fix pointing hand cursor shape Related to #1432. --- README.md | 1 + src/wl_window.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ad41c133..fc5039e8 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ information on what to include when reporting a bug. (#1462,#1528) - [X11] Bugfix: Decorations could not be enabled after window creation (#1566) - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578) + - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [NSGL] Removed enforcement of forward-compatible flag for core contexts diff --git a/src/wl_window.c b/src/wl_window.c index 200b004c..fa422ebe 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -783,7 +783,7 @@ static char *translateCursorShape(int shape) case GLFW_CROSSHAIR_CURSOR: return "crosshair"; case GLFW_HAND_CURSOR: - return "grabbing"; + return "hand2"; case GLFW_HRESIZE_CURSOR: return "sb_h_double_arrow"; case GLFW_VRESIZE_CURSOR: From 7dbdd2e6a5f01d2a4b377a197618948617517b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 7 May 2019 20:40:37 +0200 Subject: [PATCH 56/56] Add more standard cursors This adds the standard cursors for diagonal and omnidirectional resize/move and operation-not-allowed. It also adds new (better?) names for the horizontal and vertical resize/move and pointing hand cursors. References: - https://developer.apple.com/documentation/appkit/nscursor - https://stackoverflow.com/questions/10733228/ - https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setsystemcursor - https://freedesktop.org/wiki/Specifications/cursor-spec/ - https://tronche.com/gui/x/xlib/appendix/b/ Related to #427. --- README.md | 5 ++ docs/compat.dox | 7 +++ docs/input.dox | 5 +- docs/news.dox | 26 +++++++++ include/GLFW/glfw3.h | 136 +++++++++++++++++++++++++++++++++++++------ src/cocoa_window.m | 54 ++++++++++++----- src/init.c | 2 + src/input.c | 10 +++- src/win32_window.c | 17 +++++- src/wl_window.c | 105 +++++++++++++++++++++------------ src/x11_init.c | 6 ++ src/x11_platform.h | 9 +++ src/x11_window.c | 85 +++++++++++++++++++++------ tests/cursor.c | 45 +++++++------- 14 files changed, 393 insertions(+), 119 deletions(-) diff --git a/README.md b/README.md index fc5039e8..daa1be9c 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,11 @@ information on what to include when reporting a bug. ## Changelog + - 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) - Disabled tests and examples by default when built as a CMake subdirectory - Bugfix: The CMake config-file package used an absolute path and was not relocatable (#1470) diff --git a/docs/compat.dox b/docs/compat.dox index 77ba63b4..c437e350 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -85,6 +85,13 @@ transparent window framebuffers. If the running X server does not support this extension or there is no running compositing manager, the `GLFW_TRANSPARENT_FRAMEBUFFER` framebuffer hint will have no effect. +GLFW uses both the Xcursor extension and the freedesktop cursor conventions to +provide an expanded set of standard cursor shapes. If the running X server does +not support this extension or the current cursor theme does not support the +conventions, the `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR` and +`GLFW_NOT_ALLOWED_CURSOR` shapes will not be available and other shapes may use +legacy images. + @section compat_wayland Wayland protocols and IPC standards diff --git a/docs/input.dox b/docs/input.dox index dea64877..331f9718 100644 --- a/docs/input.dox +++ b/docs/input.dox @@ -373,12 +373,15 @@ A cursor with a [standard shape](@ref shapes) from the current system cursor theme can be can be created with @ref glfwCreateStandardCursor. @code -GLFWcursor* cursor = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); +GLFWcursor* url_cursor = glfwCreateStandardCursor(GLFW_POINTING_HAND_CURSOR); @endcode These cursor objects behave in the exact same way as those created with @ref glfwCreateCursor except that the system cursor theme provides the actual image. +A few of these shapes are not available everywhere. If a shape is unavailable, +`NULL` is returned. See @ref glfwCreateStandardCursor for details. + @subsubsection cursor_destruction Cursor destruction diff --git a/docs/news.dox b/docs/news.dox index 39f19031..f18537af 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -9,6 +9,24 @@ @subsection features_34 New features in version 3.4 +@subsubsection standard_cursors_34 More standard cursors + +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 omni-directional 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. + + @subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu GLFW now provides the @@ -44,6 +62,14 @@ add_subdirectory(path/to/glfw) @subsubsection types_34 New types in version 3.4 @subsubsection constants_34 New constants in version 3.4 + - @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_NOT_ALLOWED_CURSOR + - @ref GLFW_CURSOR_UNAVAILABLE - @ref GLFW_WIN32_KEYBOARD_MENU diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 0b603160..8b5b87dd 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -757,6 +757,17 @@ extern "C" { * @analysis Application programmer error. Fix the offending call. */ #define GLFW_NO_WINDOW_CONTEXT 0x0001000A +/*! @brief The specified cursor shape is not available. + * + * The specified standard cursor shape is not available, either because the + * current system cursor theme does not provide it or because it is not + * available on the platform. + * + * @analysis Platform or system settings limitation. Pick another + * [standard cursor shape](@ref shapes) or create a + * [custom cursor](@ref cursor_custom). + */ +#define GLFW_CURSOR_UNAVAILABLE 0x0001000B /*! @} */ /*! @addtogroup window @@ -1039,14 +1050,15 @@ extern "C" { /*! @defgroup shapes Standard cursor shapes * @brief Standard system cursor shapes. * - * See [standard cursor creation](@ref cursor_standard) for how these are used. + * These are the [standard cursor shapes](@ref cursor_standard) that can be + * requested from the window system. * * @ingroup input * @{ */ /*! @brief The regular arrow cursor shape. * - * The regular arrow cursor. + * The regular arrow cursor shape. */ #define GLFW_ARROW_CURSOR 0x00036001 /*! @brief The text input I-beam cursor shape. @@ -1054,26 +1066,91 @@ extern "C" { * The text input I-beam cursor shape. */ #define GLFW_IBEAM_CURSOR 0x00036002 -/*! @brief The crosshair shape. +/*! @brief The crosshair cursor shape. * - * The crosshair shape. + * The crosshair cursor shape. */ #define GLFW_CROSSHAIR_CURSOR 0x00036003 -/*! @brief The hand shape. +/*! @brief The pointing hand cursor shape. * - * The hand shape. + * The pointing hand cursor shape. */ -#define GLFW_HAND_CURSOR 0x00036004 -/*! @brief The horizontal resize arrow shape. +#define GLFW_POINTING_HAND_CURSOR 0x00036004 +/*! @brief The horizontal resize/move arrow shape. * - * The horizontal resize arrow shape. + * The horizontal resize/move arrow shape. This is usually a horizontal + * double-headed arrow. */ -#define GLFW_HRESIZE_CURSOR 0x00036005 -/*! @brief The vertical resize arrow shape. +#define GLFW_RESIZE_EW_CURSOR 0x00036005 +/*! @brief The vertical resize/move arrow shape. * - * The vertical resize arrow shape. + * The vertical resize/move shape. This is usually a vertical double-headed + * arrow. */ -#define GLFW_VRESIZE_CURSOR 0x00036006 +#define GLFW_RESIZE_NS_CURSOR 0x00036006 +/*! @brief The top-left to bottom-right diagonal resize/move arrow shape. + * + * The top-left to bottom-right diagonal resize/move shape. This is usually + * a diagonal double-headed arrow. + * + * @note @macos This shape is provided by a private system API and may fail + * with @ref GLFW_CURSOR_UNAVAILABLE in the future. + * + * @note @x11 This shape is provided by a newer standard not supported by all + * cursor themes. + * + * @note @wayland This shape is provided by a newer standard not supported by + * all cursor themes. + */ +#define GLFW_RESIZE_NWSE_CURSOR 0x00036007 +/*! @brief The top-right to bottom-left diagonal resize/move arrow shape. + * + * The top-right to bottom-left diagonal resize/move shape. This is usually + * a diagonal double-headed arrow. + * + * @note @macos This shape is provided by a private system API and may fail + * with @ref GLFW_CURSOR_UNAVAILABLE in the future. + * + * @note @x11 This shape is provided by a newer standard not supported by all + * cursor themes. + * + * @note @wayland This shape is provided by a newer standard not supported by + * all cursor themes. + */ +#define GLFW_RESIZE_NESW_CURSOR 0x00036008 +/*! @brief The omni-directional resize/move cursor shape. + * + * The omni-directional resize cursor/move shape. This is usually either + * a combined horizontal and vertical double-headed arrow or a grabbing hand. + */ +#define GLFW_RESIZE_ALL_CURSOR 0x00036009 +/*! @brief The operation-not-allowed shape. + * + * The operation-not-allowed shape. This is usually a circle with a diagonal + * line through it. + * + * @note @x11 This shape is provided by a newer standard not supported by all + * cursor themes. + * + * @note @wayland This shape is provided by a newer standard not supported by + * all cursor themes. + */ +#define GLFW_NOT_ALLOWED_CURSOR 0x0003600A +/*! @brief Legacy name for compatibility. + * + * This is an alias for compatibility with earlier versions. + */ +#define GLFW_HRESIZE_CURSOR GLFW_RESIZE_EW_CURSOR +/*! @brief Legacy name for compatibility. + * + * This is an alias for compatibility with earlier versions. + */ +#define GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR +/*! @brief Legacy name for compatibility. + * + * This is an alias for compatibility with earlier versions. + */ +#define GLFW_HAND_CURSOR GLFW_POINTING_HAND_CURSOR /*! @} */ #define GLFW_CONNECTED 0x00040001 @@ -4417,19 +4494,44 @@ GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot) /*! @brief Creates a cursor with a standard shape. * - * Returns a cursor with a [standard shape](@ref shapes), that can be set for - * a window with @ref glfwSetCursor. + * Returns a cursor with a standard shape, that can be set for a window with + * @ref glfwSetCursor. The images for these cursors come from the system + * cursor theme and their exact appearance will vary between platforms. + * + * Most of these shapes are guaranteed to exist on every supported platform but + * a few may not be present. See the table below for details. + * + * Cursor shape | Windows | macOS | X11 | Wayland + * ------------------------------ | ------- | ----- | ------ | ------- + * @ref GLFW_ARROW_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_IBEAM_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_CROSSHAIR_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_POINTING_HAND_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_RESIZE_EW_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_RESIZE_NS_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_RESIZE_NWSE_CURSOR | Yes | Yes1 | Maybe2 | Maybe2 + * @ref GLFW_RESIZE_NESW_CURSOR | Yes | Yes1 | Maybe2 | Maybe2 + * @ref GLFW_RESIZE_ALL_CURSOR | Yes | Yes | Yes | Yes + * @ref GLFW_NOT_ALLOWED_CURSOR | Yes | Yes | Maybe2 | Maybe2 + * + * 1) This uses a private system API and may fail in the future. + * + * 2) This uses a newer standard that not all cursor themes support. + * + * If the requested shape is not available, this function emits a @ref + * GLFW_CURSOR_UNAVAILABLE error and returns `NULL`. * * @param[in] shape One of the [standard shapes](@ref shapes). * @return A new cursor ready to use or `NULL` if an * [error](@ref error_handling) occurred. * * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. + * GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref + * GLFW_PLATFORM_ERROR. * * @thread_safety This function must only be called from the main thread. * - * @sa @ref cursor_object + * @sa @ref cursor_standard * @sa @ref glfwCreateCursor * * @since Added in version 3.1. diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 8e0b28aa..bfec8b7b 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1603,23 +1603,49 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { @autoreleasepool { - if (shape == GLFW_ARROW_CURSOR) - cursor->ns.object = [NSCursor arrowCursor]; - else if (shape == GLFW_IBEAM_CURSOR) - cursor->ns.object = [NSCursor IBeamCursor]; - else if (shape == GLFW_CROSSHAIR_CURSOR) - cursor->ns.object = [NSCursor crosshairCursor]; - else if (shape == GLFW_HAND_CURSOR) - cursor->ns.object = [NSCursor pointingHandCursor]; - else if (shape == GLFW_HRESIZE_CURSOR) - cursor->ns.object = [NSCursor resizeLeftRightCursor]; - else if (shape == GLFW_VRESIZE_CURSOR) - cursor->ns.object = [NSCursor resizeUpDownCursor]; + SEL cursorSelector = NULL; + + // HACK: Try to use a private message + if (shape == GLFW_RESIZE_EW_CURSOR) + cursorSelector = @selector(_windowResizeEastWestCursor); + else if (shape == GLFW_RESIZE_NS_CURSOR) + cursorSelector = @selector(_windowResizeNorthSouthCursor); + else if (shape == GLFW_RESIZE_NWSE_CURSOR) + cursorSelector = @selector(_windowResizeNorthWestSouthEastCursor); + else if (shape == GLFW_RESIZE_NESW_CURSOR) + cursorSelector = @selector(_windowResizeNorthEastSouthWestCursor); + + if (cursorSelector && [NSCursor respondsToSelector:cursorSelector]) + { + id object = [NSCursor performSelector:cursorSelector]; + if ([object isKindOfClass:[NSCursor class]]) + cursor->ns.object = object; + } if (!cursor->ns.object) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Cocoa: Failed to retrieve standard cursor"); + if (shape == GLFW_ARROW_CURSOR) + cursor->ns.object = [NSCursor arrowCursor]; + else if (shape == GLFW_IBEAM_CURSOR) + cursor->ns.object = [NSCursor IBeamCursor]; + else if (shape == GLFW_CROSSHAIR_CURSOR) + cursor->ns.object = [NSCursor crosshairCursor]; + else if (shape == GLFW_POINTING_HAND_CURSOR) + cursor->ns.object = [NSCursor pointingHandCursor]; + else if (shape == GLFW_RESIZE_EW_CURSOR) + cursor->ns.object = [NSCursor resizeLeftRightCursor]; + else if (shape == GLFW_RESIZE_NS_CURSOR) + cursor->ns.object = [NSCursor resizeUpDownCursor]; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + cursor->ns.object = [NSCursor closedHandCursor]; + else if (shape == GLFW_NOT_ALLOWED_CURSOR) + cursor->ns.object = [NSCursor operationNotAllowedCursor]; + } + + if (!cursor->ns.object) + { + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "Cocoa: Standard cursor shape unavailable"); return GLFW_FALSE; } diff --git a/src/init.c b/src/init.c index 96feab0c..13baff70 100644 --- a/src/init.c +++ b/src/init.c @@ -189,6 +189,8 @@ void _glfwInputError(int code, const char* format, ...) strcpy(description, "The requested format is unavailable"); else if (code == GLFW_NO_WINDOW_CONTEXT) strcpy(description, "The specified window has no context"); + else if (code == GLFW_CURSOR_UNAVAILABLE) + strcpy(description, "The specified cursor shape is unavailable"); else strcpy(description, "ERROR: UNKNOWN GLFW ERROR"); } diff --git a/src/input.c b/src/input.c index 28291750..f6163093 100644 --- a/src/input.c +++ b/src/input.c @@ -757,9 +757,13 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape) if (shape != GLFW_ARROW_CURSOR && shape != GLFW_IBEAM_CURSOR && shape != GLFW_CROSSHAIR_CURSOR && - shape != GLFW_HAND_CURSOR && - shape != GLFW_HRESIZE_CURSOR && - shape != GLFW_VRESIZE_CURSOR) + shape != GLFW_POINTING_HAND_CURSOR && + shape != GLFW_RESIZE_EW_CURSOR && + shape != GLFW_RESIZE_NS_CURSOR && + shape != GLFW_RESIZE_NWSE_CURSOR && + shape != GLFW_RESIZE_NESW_CURSOR && + shape != GLFW_RESIZE_ALL_CURSOR && + shape != GLFW_NOT_ALLOWED_CURSOR) { _glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor 0x%08X", shape); return NULL; diff --git a/src/win32_window.c b/src/win32_window.c index 81cdf62a..3a50c542 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2068,14 +2068,25 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) id = OCR_IBEAM; else if (shape == GLFW_CROSSHAIR_CURSOR) id = OCR_CROSS; - else if (shape == GLFW_HAND_CURSOR) + else if (shape == GLFW_POINTING_HAND_CURSOR) id = OCR_HAND; - else if (shape == GLFW_HRESIZE_CURSOR) + else if (shape == GLFW_RESIZE_EW_CURSOR) id = OCR_SIZEWE; - else if (shape == GLFW_VRESIZE_CURSOR) + else if (shape == GLFW_RESIZE_NS_CURSOR) id = OCR_SIZENS; + else if (shape == GLFW_RESIZE_NWSE_CURSOR) + id = OCR_SIZENWSE; + else if (shape == GLFW_RESIZE_NESW_CURSOR) + id = OCR_SIZENESW; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + id = OCR_SIZEALL; + else if (shape == GLFW_NOT_ALLOWED_CURSOR) + id = OCR_NO; else + { + _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor"); return GLFW_FALSE; + } cursor->win32.handle = LoadImageW(NULL, MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0, diff --git a/src/wl_window.c b/src/wl_window.c index fa422ebe..c8dde30a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -770,28 +770,6 @@ static void handleEvents(int timeout) } } -// Translates a GLFW standard cursor to a theme cursor name -// -static char *translateCursorShape(int shape) -{ - switch (shape) - { - case GLFW_ARROW_CURSOR: - return "left_ptr"; - case GLFW_IBEAM_CURSOR: - return "xterm"; - case GLFW_CROSSHAIR_CURSOR: - return "crosshair"; - case GLFW_HAND_CURSOR: - return "hand2"; - case GLFW_HRESIZE_CURSOR: - return "sb_h_double_arrow"; - case GLFW_VRESIZE_CURSOR: - return "sb_v_double_arrow"; - } - return NULL; -} - ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// @@ -1233,26 +1211,79 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { - struct wl_cursor* standardCursor; + const char* name = NULL; - standardCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, - translateCursorShape(shape)); - if (!standardCursor) - { - _glfwInputError(GLFW_PLATFORM_ERROR, - "Wayland: Standard cursor \"%s\" not found", - translateCursorShape(shape)); - return GLFW_FALSE; - } + // Try the XDG names first + if (shape == GLFW_ARROW_CURSOR) + name = "default"; + else if (shape == GLFW_IBEAM_CURSOR) + name = "text"; + else if (shape == GLFW_CROSSHAIR_CURSOR) + name = "crosshair"; + else if (shape == GLFW_POINTING_HAND_CURSOR) + name = "pointer"; + else if (shape == GLFW_RESIZE_EW_CURSOR) + name = "ew-resize"; + else if (shape == GLFW_RESIZE_NS_CURSOR) + name = "ns-resize"; + else if (shape == GLFW_RESIZE_NWSE_CURSOR) + name = "nwse-resize"; + else if (shape == GLFW_RESIZE_NESW_CURSOR) + name = "nesw-resize"; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + name = "all-scroll"; + else if (shape == GLFW_NOT_ALLOWED_CURSOR) + name = "not-allowed"; - cursor->wl.cursor = standardCursor; - cursor->wl.currentImage = 0; + cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); if (_glfw.wl.cursorThemeHiDPI) { - standardCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, - translateCursorShape(shape)); - cursor->wl.cursorHiDPI = standardCursor; + cursor->wl.cursorHiDPI = + wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name); + } + + if (!cursor->wl.cursor) + { + // Fall back to the core X11 names + if (shape == GLFW_ARROW_CURSOR) + name = "left_ptr"; + else if (shape == GLFW_IBEAM_CURSOR) + name = "xterm"; + else if (shape == GLFW_CROSSHAIR_CURSOR) + name = "crosshair"; + else if (shape == GLFW_POINTING_HAND_CURSOR) + name = "hand2"; + else if (shape == GLFW_RESIZE_EW_CURSOR) + name = "sb_h_double_arrow"; + else if (shape == GLFW_RESIZE_NS_CURSOR) + name = "sb_v_double_arrow"; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + name = "fleur"; + else + { + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "Wayland: Standard cursor shape unavailable"); + return GLFW_FALSE; + } + + cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); + if (!cursor->wl.cursor) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create standard cursor \"%s\"", + name); + return GLFW_FALSE; + } + + if (_glfw.wl.cursorThemeHiDPI) + { + if (!cursor->wl.cursorHiDPI) + { + cursor->wl.cursorHiDPI = + wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name); + } + } } return GLFW_TRUE; diff --git a/src/x11_init.c b/src/x11_init.c index ca8b2ff2..d44d4e2a 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -615,6 +615,12 @@ static GLFWbool initExtensions(void) _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy"); _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor) _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor"); + _glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme) + _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetTheme"); + _glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize) + _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize"); + _glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage) + _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage"); } #if defined(__CYGWIN__) diff --git a/src/x11_platform.h b/src/x11_platform.h index 33145e63..cb3b1068 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -85,9 +85,15 @@ typedef int (* PFN_XRRUpdateConfiguration)(XEvent*); typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int); typedef void (* PFN_XcursorImageDestroy)(XcursorImage*); typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*); +typedef char* (* PFN_XcursorGetTheme)(Display*); +typedef int (* PFN_XcursorGetDefaultSize)(Display*); +typedef XcursorImage* (* PFN_XcursorLibraryLoadImage)(const char*,const char*,int); #define XcursorImageCreate _glfw.x11.xcursor.ImageCreate #define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy #define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor +#define XcursorGetTheme _glfw.x11.xcursor.GetTheme +#define XcursorGetDefaultSize _glfw.x11.xcursor.GetDefaultSize +#define XcursorLibraryLoadImage _glfw.x11.xcursor.LibraryLoadImage typedef Bool (* PFN_XineramaIsActive)(Display*); typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*); @@ -352,6 +358,9 @@ typedef struct _GLFWlibraryX11 PFN_XcursorImageCreate ImageCreate; PFN_XcursorImageDestroy ImageDestroy; PFN_XcursorImageLoadCursor ImageLoadCursor; + PFN_XcursorGetTheme GetTheme; + PFN_XcursorGetDefaultSize GetDefaultSize; + PFN_XcursorLibraryLoadImage LibraryLoadImage; } xcursor; struct { diff --git a/src/x11_window.c b/src/x11_window.c index 56379a3c..9f0312ce 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2823,29 +2823,76 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { - int native = 0; + if (_glfw.x11.xcursor.handle) + { + char* theme = XcursorGetTheme(_glfw.x11.display); + if (theme) + { + const int size = XcursorGetDefaultSize(_glfw.x11.display); + const char* name = NULL; - if (shape == GLFW_ARROW_CURSOR) - native = XC_left_ptr; - else if (shape == GLFW_IBEAM_CURSOR) - native = XC_xterm; - else if (shape == GLFW_CROSSHAIR_CURSOR) - native = XC_crosshair; - else if (shape == GLFW_HAND_CURSOR) - native = XC_hand2; - else if (shape == GLFW_HRESIZE_CURSOR) - native = XC_sb_h_double_arrow; - else if (shape == GLFW_VRESIZE_CURSOR) - native = XC_sb_v_double_arrow; - else - return GLFW_FALSE; + if (shape == GLFW_ARROW_CURSOR) + name = "default"; + else if (shape == GLFW_IBEAM_CURSOR) + name = "text"; + else if (shape == GLFW_CROSSHAIR_CURSOR) + name = "crosshair"; + else if (shape == GLFW_POINTING_HAND_CURSOR) + name = "pointer"; + else if (shape == GLFW_RESIZE_EW_CURSOR) + name = "ew-resize"; + else if (shape == GLFW_RESIZE_NS_CURSOR) + name = "ns-resize"; + else if (shape == GLFW_RESIZE_NWSE_CURSOR) + name = "nwse-resize"; + else if (shape == GLFW_RESIZE_NESW_CURSOR) + name = "nesw-resize"; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + name = "all-scroll"; + else if (shape == GLFW_NOT_ALLOWED_CURSOR) + name = "not-allowed"; + + XcursorImage* image = XcursorLibraryLoadImage(name, theme, size); + if (image) + { + cursor->x11.handle = XcursorImageLoadCursor(_glfw.x11.display, image); + XcursorImageDestroy(image); + } + } + } - cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native); if (!cursor->x11.handle) { - _glfwInputError(GLFW_PLATFORM_ERROR, - "X11: Failed to create standard cursor"); - return GLFW_FALSE; + unsigned int native = 0; + + if (shape == GLFW_ARROW_CURSOR) + native = XC_left_ptr; + else if (shape == GLFW_IBEAM_CURSOR) + native = XC_xterm; + else if (shape == GLFW_CROSSHAIR_CURSOR) + native = XC_crosshair; + else if (shape == GLFW_POINTING_HAND_CURSOR) + native = XC_hand2; + else if (shape == GLFW_RESIZE_EW_CURSOR) + native = XC_sb_h_double_arrow; + else if (shape == GLFW_RESIZE_NS_CURSOR) + native = XC_sb_v_double_arrow; + else if (shape == GLFW_RESIZE_ALL_CURSOR) + native = XC_fleur; + else + { + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "X11: Standard cursor shape unavailable"); + return GLFW_FALSE; + } + + cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native); + if (!cursor->x11.handle) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "X11: Failed to create standard cursor"); + return GLFW_FALSE; + } } return GLFW_TRUE; diff --git a/tests/cursor.c b/tests/cursor.c index b6288f6a..f72c0f91 100644 --- a/tests/cursor.c +++ b/tests/cursor.c @@ -69,7 +69,7 @@ static int swap_interval = 1; static int wait_events = GLFW_TRUE; static int animate_cursor = GLFW_FALSE; static int track_cursor = GLFW_FALSE; -static GLFWcursor* standard_cursors[6]; +static GLFWcursor* standard_cursors[10]; static GLFWcursor* tracking_cursor = NULL; static void error_callback(int error, const char* description) @@ -271,28 +271,24 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, break; case GLFW_KEY_1: - glfwSetCursor(window, standard_cursors[0]); - break; - case GLFW_KEY_2: - glfwSetCursor(window, standard_cursors[1]); - break; - case GLFW_KEY_3: - glfwSetCursor(window, standard_cursors[2]); - break; - case GLFW_KEY_4: - glfwSetCursor(window, standard_cursors[3]); - break; - case GLFW_KEY_5: - glfwSetCursor(window, standard_cursors[4]); - break; - case GLFW_KEY_6: - glfwSetCursor(window, standard_cursors[5]); + case GLFW_KEY_7: + case GLFW_KEY_8: + case GLFW_KEY_9: + { + int index = key - GLFW_KEY_1; + if (mods & GLFW_MOD_SHIFT) + index += 9; + + if (index < sizeof(standard_cursors) / sizeof(standard_cursors[0])) + glfwSetCursor(window, standard_cursors[index]); + break; + } case GLFW_KEY_F11: case GLFW_KEY_ENTER: @@ -358,17 +354,16 @@ int main(void) GLFW_ARROW_CURSOR, GLFW_IBEAM_CURSOR, GLFW_CROSSHAIR_CURSOR, - GLFW_HAND_CURSOR, - GLFW_HRESIZE_CURSOR, - GLFW_VRESIZE_CURSOR + GLFW_POINTING_HAND_CURSOR, + GLFW_RESIZE_EW_CURSOR, + GLFW_RESIZE_NS_CURSOR, + GLFW_RESIZE_NWSE_CURSOR, + GLFW_RESIZE_NESW_CURSOR, + GLFW_RESIZE_ALL_CURSOR, + GLFW_NOT_ALLOWED_CURSOR }; standard_cursors[i] = glfwCreateStandardCursor(shapes[i]); - if (!standard_cursors[i]) - { - glfwTerminate(); - exit(EXIT_FAILURE); - } } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);