From 761f97d6b600794062bc2c6055d7d09ae6a567fc Mon Sep 17 00:00:00 2001 From: ashishgamedev <66940640+ashishgamedev@users.noreply.github.com> Date: Thu, 10 Dec 2020 19:48:55 +0530 Subject: [PATCH 01/26] Fix indentation in internal.h Closes #1818. --- src/internal.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/internal.h b/src/internal.h index 48053cde..f87c2f93 100644 --- a/src/internal.h +++ b/src/internal.h @@ -350,9 +350,9 @@ struct _GLFWcontext int robustness; int release; - PFNGLGETSTRINGIPROC GetStringi; + PFNGLGETSTRINGIPROC GetStringi; PFNGLGETINTEGERVPROC GetIntegerv; - PFNGLGETSTRINGPROC GetString; + PFNGLGETSTRINGPROC GetString; _GLFWmakecontextcurrentfun makeCurrent; _GLFWswapbuffersfun swapBuffers; @@ -405,23 +405,23 @@ struct _GLFWwindow _GLFWcontext context; struct { - GLFWwindowposfun pos; - GLFWwindowsizefun size; - GLFWwindowclosefun close; - GLFWwindowrefreshfun refresh; - GLFWwindowfocusfun focus; - GLFWwindowiconifyfun iconify; - GLFWwindowmaximizefun maximize; - GLFWframebuffersizefun fbsize; + GLFWwindowposfun pos; + GLFWwindowsizefun size; + GLFWwindowclosefun close; + GLFWwindowrefreshfun refresh; + GLFWwindowfocusfun focus; + GLFWwindowiconifyfun iconify; + GLFWwindowmaximizefun maximize; + GLFWframebuffersizefun fbsize; GLFWwindowcontentscalefun scale; - GLFWmousebuttonfun mouseButton; - GLFWcursorposfun cursorPos; - GLFWcursorenterfun cursorEnter; - GLFWscrollfun scroll; - GLFWkeyfun key; - GLFWcharfun character; - GLFWcharmodsfun charmods; - GLFWdropfun drop; + GLFWmousebuttonfun mouseButton; + GLFWcursorposfun cursorPos; + GLFWcursorenterfun cursorEnter; + GLFWscrollfun scroll; + GLFWkeyfun key; + GLFWcharfun character; + GLFWcharmodsfun charmods; + GLFWdropfun drop; } callbacks; // This is defined in the window API's platform.h From 6ce6b50787e058177aad547aac33015ab298f1f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 15 Dec 2020 02:13:24 +0100 Subject: [PATCH 02/26] Add credit Related to #1818. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b4d798b9..71266cf7 100644 --- a/README.md +++ b/README.md @@ -247,6 +247,7 @@ skills. - Bobyshev Alexander - Matt Arsenault + - ashishgamedev - David Avedissian - Keith Bauer - John Bartholomew From 3a8ebb1903bd556c21c80c23c42da361b143a051 Mon Sep 17 00:00:00 2001 From: Luke Bayes Date: Sat, 2 Jan 2021 19:55:31 -0500 Subject: [PATCH 03/26] Added 2 entries to the gitignores file. I downloaded and built from sources as as submodule for a personal exploration that I'm working on and discovered that the glfw submodule shows changed files after a build. Adding these 2 entries fixes the issue. Closes #1827. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b34fc452..84636a0a 100644 --- a/.gitignore +++ b/.gitignore @@ -77,6 +77,7 @@ examples/splitview examples/sharing examples/triangle-opengl examples/wave +examples/windows tests/*.app tests/*.exe tests/clipboard @@ -87,6 +88,7 @@ tests/gamma tests/glfwinfo tests/icon tests/iconify +tests/inputlag tests/joysticks tests/monitors tests/msaa From 5d1d1a01e3a05c068289487831940896d9a5902e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 3 Jan 2021 21:13:02 +0100 Subject: [PATCH 04/26] Update repo URL for Nuklear Fixes #1826. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71266cf7..a7a1d738 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ located in the `deps/` directory. functions - [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in examples - - [Nuklear](https://github.com/vurtun/nuklear) for test and example UI + - [Nuklear](https://github.com/Immediate-Mode-UI/Nuklear) for test and example UI - [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can From f5af421a6b9910ae8d02c4f468ec6d130052c351 Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Tue, 5 Jan 2021 20:42:46 -0800 Subject: [PATCH 05/26] Cocoa: Fix duplicate video mode detection Closes #1830. --- 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 2bb83738..d0112d26 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -527,7 +527,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count) } // Skip duplicate modes - if (i < *count) + if (j < *count) continue; (*count)++; From 552209fe465b3c3d8bc4e2b02e0b259364d2a3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Jan 2021 16:24:27 +0100 Subject: [PATCH 06/26] Update changelog --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a7a1d738..5e06e990 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays could leak memory - [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787) + - [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830) - [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) From 8b118674643b199fc28d11dc22039ffe528970b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 8 Dec 2020 23:23:20 +0100 Subject: [PATCH 07/26] Cocoa: Fix menubar for unbundled apps on 10.15 NSApp setActivationPolicy: was being called too soon when the app was not bundled and launched from the command line. This fix is based on #1802 by @richardwilkes. Fixes #1648. Closes #1802. --- README.md | 3 +++ src/cocoa_init.m | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5e06e990..5b76f5bb 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,8 @@ information on what to include when reporting a bug. could leak memory - [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787) - [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830) + - [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and + regained focus (#1648,#1802) - [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) @@ -441,6 +443,7 @@ skills. - Frank Wille - Andy Williams - Joel Winarske + - Richard A. Wilkes - Tatsuya Yatagawa - Ryogo Yoshimura - Lukas Zanner diff --git a/src/cocoa_init.m b/src/cocoa_init.m index edd174be..88decab6 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -428,9 +428,6 @@ static GLFWbool initializeTIS(void) { if (_glfw.hints.init.ns.menubar) { - // In case we are unbundled, make us a proper UI application - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - // Menu bar setup must go between sharedApplication and finishLaunching // in order to properly emulate the behavior of NSApplicationMain @@ -557,6 +554,9 @@ int _glfwPlatformInit(void) if (![[NSRunningApplication currentApplication] isFinishedLaunching]) [NSApp run]; + // In case we are unbundled, make us a proper UI application + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + return GLFW_TRUE; } // autoreleasepool From 5aff72aa0016105477b9ce16f2da590939cec981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Jan 2021 01:26:00 +0100 Subject: [PATCH 08/26] Cocoa: Fix duplicate monitor connection events --- src/cocoa_monitor.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index d0112d26..8891f8a6 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -338,7 +338,8 @@ void _glfwPollMonitorsNS(void) // display replacement on machines with automatic graphics // switching const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); - for (uint32_t j = 0; j < disconnectedCount; j++) + uint32_t j; + for (j = 0; j < disconnectedCount; j++) { if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber) { @@ -347,6 +348,9 @@ void _glfwPollMonitorsNS(void) } } + if (j < disconnectedCount) + continue; + const CGSize size = CGDisplayScreenSize(displays[i]); char* name = getDisplayName(displays[i]); if (!name) From 2bc52ca82e46f6f238007b8e80b7253328bd080d Mon Sep 17 00:00:00 2001 From: Nevyn Bengtsson Date: Mon, 11 Jan 2021 17:27:27 +0100 Subject: [PATCH 09/26] Cocoa: Use modern API to get display name On Apple Silicon, IOKit is deprecated and there will be no matching io_service that we can query for name. Luckilly, NSScreen got an API to fetch the display name in 10.15. This is a blocker to get glfw running on Apple Silicon. Fixes #1809. Closes #1833. --- src/cocoa_monitor.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index 8891f8a6..d85d2621 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -41,6 +41,22 @@ // static char* getDisplayName(CGDirectDisplayID displayID) { + // IOKit doesn't work on Apple Silicon anymore. Luckilly, 10.15 introduced -[NSScreen localizedName]. + // Use it if available, and fall back to IOKit otherwise. + if ([NSScreen instancesRespondToSelector:@selector(localizedName)]) + { + for(NSScreen *screen in [NSScreen screens]) + { + if ([[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue] == displayID) + { + NSString *name = [screen valueForKey:@"localizedName"]; + if (name) + { + return _glfw_strdup([name UTF8String]); + } + } + } + } io_iterator_t it; io_service_t service; CFDictionaryRef info; From 8ab40399d3bdbf8fb9501e42e53f36b5e5528da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Jan 2021 01:34:55 +0100 Subject: [PATCH 10/26] Update changelog and add credit Related to #1833. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5b76f5bb..f5783f5c 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Duplicate video modes were not filtered out (#1830) - [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and regained focus (#1648,#1802) + - [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833) - [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) @@ -257,6 +258,7 @@ skills. - Coşku Baş - Niklas Behrens - Andrew Belt + - Nevyn Bengtsson - Niklas Bergström - Denis Bernard - Doug Binks From 3959ee894952f7dcba4e46bdd5d34e4528701cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 17 Jan 2021 19:49:51 +0100 Subject: [PATCH 11/26] Cocoa: Unify CG display to NS screen mapping This moves the matching of CG displays to NS screens to monitor enumeration time. --- src/cocoa_monitor.m | 79 +++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 43 deletions(-) diff --git a/src/cocoa_monitor.m b/src/cocoa_monitor.m index d85d2621..8eb3f70d 100644 --- a/src/cocoa_monitor.m +++ b/src/cocoa_monitor.m @@ -39,24 +39,21 @@ // Get the name of the specified display, or NULL // -static char* getDisplayName(CGDirectDisplayID displayID) +static char* getMonitorName(CGDirectDisplayID displayID, NSScreen* screen) { - // IOKit doesn't work on Apple Silicon anymore. Luckilly, 10.15 introduced -[NSScreen localizedName]. + // IOKit doesn't work on Apple Silicon anymore + // Luckily, 10.15 introduced -[NSScreen localizedName]. // Use it if available, and fall back to IOKit otherwise. - if ([NSScreen instancesRespondToSelector:@selector(localizedName)]) + if (screen) { - for(NSScreen *screen in [NSScreen screens]) + if ([screen respondsToSelector:@selector(localizedName)]) { - if ([[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue] == displayID) - { - NSString *name = [screen valueForKey:@"localizedName"]; - if (name) - { - return _glfw_strdup([name UTF8String]); - } - } + NSString* name = [screen valueForKey:@"localizedName"]; + if (name) + return _glfw_strdup([name UTF8String]); } } + io_iterator_t it; io_service_t service; CFDictionaryRef info; @@ -225,31 +222,6 @@ static void endFadeReservation(CGDisplayFadeReservationToken token) } } -// Finds and caches the NSScreen corresponding to the specified monitor -// -static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor) -{ - if (monitor->ns.screen) - return GLFW_TRUE; - - for (NSScreen* screen in [NSScreen screens]) - { - NSNumber* displayID = [screen deviceDescription][@"NSScreenNumber"]; - - // HACK: Compare unit numbers instead of display IDs to work around - // display replacement on machines with automatic graphics - // switching - if (monitor->ns.unitNumber == CGDisplayUnitNumber([displayID unsignedIntValue])) - { - monitor->ns.screen = screen; - return GLFW_TRUE; - } - } - - _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor"); - return GLFW_FALSE; -} - // Returns the display refresh rate queried from the I/O registry // static double getFallbackRefreshRate(CGDirectDisplayID displayID) @@ -350,15 +322,29 @@ void _glfwPollMonitorsNS(void) if (CGDisplayIsAsleep(displays[i])) continue; + const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); + NSScreen* screen = nil; + + for (screen in [NSScreen screens]) + { + NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"]; + + // HACK: Compare unit numbers instead of display IDs to work around + // display replacement on machines with automatic graphics + // switching + if (CGDisplayUnitNumber([screenNumber unsignedIntValue]) == unitNumber) + break; + } + // HACK: Compare unit numbers instead of display IDs to work around // display replacement on machines with automatic graphics // switching - const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]); uint32_t j; for (j = 0; j < disconnectedCount; j++) { if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber) { + disconnected[j]->ns.screen = screen; disconnected[j] = NULL; break; } @@ -368,13 +354,14 @@ void _glfwPollMonitorsNS(void) continue; const CGSize size = CGDisplayScreenSize(displays[i]); - char* name = getDisplayName(displays[i]); + char* name = getMonitorName(displays[i], screen); if (!name) name = _glfw_strdup("Unknown"); _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height); monitor->ns.displayID = displays[i]; monitor->ns.unitNumber = unitNumber; + monitor->ns.screen = screen; free(name); @@ -483,8 +470,11 @@ void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor, { @autoreleasepool { - if (!refreshMonitorScreen(monitor)) - return; + if (!monitor->ns.screen) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Cannot query content scale without screen"); + } const NSRect points = [monitor->ns.screen frame]; const NSRect pixels = [monitor->ns.screen convertRectToBacking:points]; @@ -503,8 +493,11 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, { @autoreleasepool { - if (!refreshMonitorScreen(monitor)) - return; + if (!monitor->ns.screen) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Cocoa: Cannot query workarea without screen"); + } const NSRect frameRect = [monitor->ns.screen visibleFrame]; From f8d6801a507ff5a5b41f30347dd03f1e38a0f9e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Jan 2021 16:04:51 +0100 Subject: [PATCH 12/26] Simplify references in CMake if-statements --- src/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a45ea50..4a0f5340 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,7 +37,7 @@ elseif (_GLFW_OSMESA) endif() if (_GLFW_X11 OR _GLFW_WAYLAND) - if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c) else() target_sources(glfw PRIVATE null_joystick.h null_joystick.c) @@ -120,7 +120,7 @@ endif() # Make GCC warn about declarations that VS 2010 and 2012 won't accept for all # source files that VS will build (Clang ignores this because we set -std=c99) -if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") +if (CMAKE_C_COMPILER_ID STREQUAL "GNU") set_source_files_properties(context.c init.c input.c monitor.c vulkan.c window.c win32_init.c win32_joystick.c win32_monitor.c win32_time.c win32_thread.c @@ -130,11 +130,11 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") endif() # Enable a reasonable set of warnings -if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR - "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR - "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") +if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR + CMAKE_C_COMPILER_ID STREQUAL "Clang" OR + CMAKE_C_COMPILER_ID STREQUAL "AppleClang") - if ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") + if (CMAKE_C_SIMULATE_ID STREQUAL "MSVC") # Tell Clang-CL that this is a Clang flag target_compile_options(glfw PRIVATE "/clang:-Wall") else() From 384ff74a4645347bbc5726fc572138b38f87ae8b Mon Sep 17 00:00:00 2001 From: Laurent Aphecetche Date: Fri, 14 Jun 2019 16:42:50 +0200 Subject: [PATCH 13/26] Cocoa: Fix install name for installed dylib The install name was incorrectly set to a relative path. This change leaves the install name of the installed dylib as @rpath/soname. Those who wish to override this can set the CMAKE_INSTALL_NAME_DIR variable. Closes #1504. --- src/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4a0f5340..2e6a1fa2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -203,9 +203,6 @@ if (BUILD_SHARED_LIBS) endif() target_compile_definitions(glfw INTERFACE GLFW_DLL) - elseif (APPLE) - set_target_properties(glfw PROPERTIES - INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}") endif() if (MINGW) From 94773111300fee0453844a4c9407af7e880b4df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 18 Jan 2021 18:55:17 +0100 Subject: [PATCH 14/26] Update changelog and add credit --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f5783f5c..3185b6cc 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ information on what to include when reporting a bug. - [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and regained focus (#1648,#1802) - [Cocoa] Bugfix: Monitor name query could segfault on macOS 11 (#1809,#1833) + - [Cocoa] Bugfix: The install name of the installed dylib was relative (#1504) - [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) @@ -250,6 +251,7 @@ GLFW exists because people around the world donated their time and lent their skills. - Bobyshev Alexander + - Laurent Aphecetche - Matt Arsenault - ashishgamedev - David Avedissian From 6de084000bbebec345f4e5845a92fb2f4f931c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 10 Feb 2021 17:23:43 +0100 Subject: [PATCH 15/26] Cocoa: Fix console apps getting a dock icon Regression introduced by @elmindreda in 8b118674643b199fc28d11dc22039ffe528970b3. --- src/cocoa_init.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 88decab6..626d95c2 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -555,7 +555,8 @@ int _glfwPlatformInit(void) [NSApp run]; // In case we are unbundled, make us a proper UI application - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + if (_glfw.hints.init.ns.menubar) + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; return GLFW_TRUE; From 410890aa8058a0c5a33f2e00d750326ba412e466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 19 Jan 2021 22:25:05 +0100 Subject: [PATCH 16/26] Win32: Fix full screen windows affected by scaling Per-monitor DPI scaling should not affect full screen windows. Fixes #1582. --- README.md | 2 ++ src/win32_window.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3185b6cc..73dc1acd 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,8 @@ information on what to include when reporting a bug. configuration change (#1761) - [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775) - [Win32] Bugfix: Duplicate size events were not filtered (#1610) + - [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes + (#1582) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_window.c b/src/win32_window.c index febafae4..1fa4570a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1140,7 +1140,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // Only apply the suggested size if the OS is new enough to have // sent a WM_GETDPISCALEDSIZE before this - if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32()) + if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32() && !window->monitor) { RECT* suggested = (RECT*) lParam; SetWindowPos(window->win32.handle, HWND_TOP, From 729c9988d02004faac1663c18c7628bae193a95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 20 Jan 2021 01:02:24 +0100 Subject: [PATCH 17/26] Win32: Fix content area rescaling on older systems GLFW_SCALE_TO_MONITOR had no effect on Windows 8.1 up to and including Windows 10 version 1607 (Anniversary Update), despite those having support for per-monitor DPI. That done was to avoid handling systems that have non-client scaling, introduced in Windows 10 version 1607, without reliable overriding of the new window size, introduced in Windows 10 version 1703 (Creators Update). Both are needed to keep the content area at a fixed size for windows that have GLFW_SCALE_TO_MONITOR disabled. This change enables window rescaling on Windows 8.1 and all later versions but disables non-client scaling for unscaled windows on Windows 10 version 1607. Versions after 1607 are unaffected. Fixes #1511. --- README.md | 2 ++ src/win32_window.c | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 73dc1acd..b0774fc4 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Duplicate size events were not filtered (#1610) - [Win32] Bugfix: Full screen windows were incorrectly resized by DPI changes (#1582) + - [Win32] Bugfix: `GLFW_SCALE_TO_MONITOR` had no effect on systems older than + Windows 10 version 1703 (#1511) - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619) - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) diff --git a/src/win32_window.c b/src/win32_window.c index 1fa4570a..52a9c680 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -501,7 +501,17 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_NCCREATE: { if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32()) - EnableNonClientDpiScaling(hWnd); + { + const CREATESTRUCTW* cs = (const CREATESTRUCTW*) lParam; + const _GLFWwndconfig* wndconfig = cs->lpCreateParams; + + // On per-monitor DPI aware V1 systems, only enable + // non-client scaling for windows that scale the client area + // We need WM_GETDPISCALEDSIZE from V2 to keep the client + // area static when the non-client area is scaled + if (wndconfig && wndconfig->scaleToMonitor) + EnableNonClientDpiScaling(hWnd); + } break; } @@ -1138,9 +1148,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI; const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI; - // Only apply the suggested size if the OS is new enough to have - // sent a WM_GETDPISCALEDSIZE before this - if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32() && !window->monitor) + // Resize windowed mode windows that either permit rescaling or that + // need it to compensate for non-client area scaling + if (!window->monitor && + (window->win32.scaleToMonitor || + _glfwIsWindows10CreatorsUpdateOrGreaterWin32())) { RECT* suggested = (RECT*) lParam; SetWindowPos(window->win32.handle, HWND_TOP, @@ -1255,7 +1267,7 @@ static int createNativeWindow(_GLFWwindow* window, NULL, // No parent window NULL, // No window menu GetModuleHandleW(NULL), - NULL); + (LPVOID) wndconfig); free(wideTitle); From b925a54ef11adab250e4e9592afe918c1f8caebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 9 Feb 2021 21:33:23 +0100 Subject: [PATCH 18/26] Wayland: Move DPI fallback work to output done This removes the dependency on the (unspecified) ordering of geometry and mode events in wl_output. Based on feedback from @linkmauve and @caramelli. Related to #1792. --- src/wl_monitor.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/wl_monitor.c b/src/wl_monitor.c index 4cbfb51d..d722beaa 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -81,22 +81,21 @@ static void outputHandleMode(void* data, monitor->modes[monitor->modeCount - 1] = mode; if (flags & WL_OUTPUT_MODE_CURRENT) - { monitor->wl.currentMode = monitor->modeCount - 1; - - if (monitor->widthMM <= 0 || monitor->heightMM <= 0) - { - // If Wayland does not provide a physical size, assume the default 96 DPI - monitor->widthMM = (int) (width * 25.4f / 96.f); - monitor->heightMM = (int) (height * 25.4f / 96.f); - } - } } static void outputHandleDone(void* data, struct wl_output* output) { struct _GLFWmonitor *monitor = data; + if (monitor->widthMM <= 0 || monitor->heightMM <= 0) + { + // If Wayland does not provide a physical size, assume the default 96 DPI + const GLFWvidmode* mode = &monitor->modes[monitor->wl.currentMode]; + monitor->widthMM = (int) (mode->width * 25.4f / 96.f); + monitor->heightMM = (int) (mode->height * 25.4f / 96.f); + } + _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); } From 2c7f3ce91b4f22773855c43d6480824ed4ac9907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 17 Feb 2021 21:21:49 +0100 Subject: [PATCH 19/26] Update changelog --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b0774fc4..b9b047f0 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,7 @@ information on what to include when reporting a bug. (#1463) - [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder (#1798) + - [Wayland] Bugfix: Monitors physical size could report zero (#1784,#1792) - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled - [NSGL] Removed enforcement of forward-compatible flag for core contexts - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer From 4afa227a056681d2628894b0893527bf69496a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 8 Mar 2021 19:32:36 +0100 Subject: [PATCH 20/26] X11: Fix attribs not applied on leaving fullscreen If the GLFW_DECORATED and/or GLFW_FLOATING window attributes were changed while in fullscreen mode, the changes did not take effect when the window entered windowed mode. Bug reported on the GLFW forum. https://discourse.glfw.org/t/turning-on-off-window-decorations-while-in-full-screen-wont-work-properly/1780 --- README.md | 1 + src/x11_window.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index b9b047f0..9e4f2df9 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,7 @@ information on what to include when reporting a bug. combinaitons (#1598) - [X11] Bugfix: Keys pressed simultaneously with others were not always reported (#1112,#1415,#1472,#1616) + - [X11] Bugfix: Some window attributes were not applied on leaving fullscreen - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled diff --git a/src/x11_window.c b/src/x11_window.c index a85688e1..3f2277d6 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2485,7 +2485,11 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, } if (window->monitor) + { + _glfwPlatformSetWindowDecorated(window, window->decorated); + _glfwPlatformSetWindowFloating(window, window->floating); releaseMonitor(window); + } _glfwInputWindowMonitor(window, monitor); updateNormalHints(window, width, height); From 1f34295a74ecbbe87d95ad39ce1cd0d943f88dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 9 Mar 2021 23:36:05 +0100 Subject: [PATCH 21/26] Win32: Add MinGW-w64 detection to version string --- src/win32_init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/win32_init.c b/src/win32_init.c index f6995e51..4cd6f158 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -614,7 +614,9 @@ void _glfwPlatformTerminate(void) const char* _glfwPlatformGetVersionString(void) { return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa" -#if defined(__MINGW32__) +#if defined(__MINGW64_VERSION_MAJOR) + " MinGW-w64" +#elif defined(__MINGW32__) " MinGW" #elif defined(_MSC_VER) " VisualC" From 9c62a21ba91d347617856dee9ccdf6da1175a83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 10 Mar 2021 21:39:16 +0100 Subject: [PATCH 22/26] Update linmath.h --- deps/linmath.h | 151 +++++++++++++++++++++---------------------------- 1 file changed, 66 insertions(+), 85 deletions(-) diff --git a/deps/linmath.h b/deps/linmath.h index 8b2a8c2e..be37caf6 100644 --- a/deps/linmath.h +++ b/deps/linmath.h @@ -1,13 +1,8 @@ #ifndef LINMATH_H #define LINMATH_H +#include #include - -/* 2020-03-02 Camilla Löwy - * - Added inclusion of string.h for memcpy - * - Replaced tan and acos with tanf and acosf - * - Replaced double constants with float equivalents - */ #include #ifdef LINMATH_NO_INLINE @@ -38,7 +33,7 @@ LINMATH_H_FUNC void vec##n##_scale(vec##n r, vec##n const v, float const s) \ } \ LINMATH_H_FUNC float vec##n##_mul_inner(vec##n const a, vec##n const b) \ { \ - float p = 0.; \ + float p = 0.f; \ int i; \ for(i=0; ib[i] ? a[i] : b[i]; \ +} \ +LINMATH_H_FUNC void vec##n##_dup(vec##n r, vec##n const src) \ +{ \ + int i; \ + for(i=0; i Date: Thu, 20 Aug 2020 12:54:07 +0200 Subject: [PATCH 23/26] Ignore cached state when setting window attributes This filtering prevented valid changes if the native window state was changed externally. --- src/window.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/window.c b/src/window.c index efcb4125..d2196e2f 100644 --- a/src/window.c +++ b/src/window.c @@ -882,27 +882,18 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) window->autoIconify = value; else if (attrib == GLFW_RESIZABLE) { - if (window->resizable == value) - return; - window->resizable = value; if (!window->monitor) _glfwPlatformSetWindowResizable(window, value); } else if (attrib == GLFW_DECORATED) { - if (window->decorated == value) - return; - window->decorated = value; if (!window->monitor) _glfwPlatformSetWindowDecorated(window, value); } else if (attrib == GLFW_FLOATING) { - if (window->floating == value) - return; - window->floating = value; if (!window->monitor) _glfwPlatformSetWindowFloating(window, value); @@ -911,9 +902,6 @@ GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value) window->focusOnShow = value; else if (attrib == GLFW_MOUSE_PASSTHROUGH) { - if (window->mousePassthrough == value) - return; - window->mousePassthrough = value; _glfwPlatformSetWindowMousePassthrough(window, value); } From 52ba8c7f07574d56955099179f35569e07e2001c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 15 Mar 2021 00:48:05 +0100 Subject: [PATCH 24/26] Win32: Add warning when option will have no effect The GPU driver only looks in the executable for the symbol requesting the high-performance GPU, so enabling them when buidling GLFW as a DLL will have no effect. --- src/win32_init.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/win32_init.c b/src/win32_init.c index 4cd6f158..970da06e 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -39,6 +39,10 @@ static const GUID _glfw_GUID_DEVINTERFACE_HID = #if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG) +#if defined(_GLFW_BUILD_DLL) + #warning "These symbols must be exported by the executable and have no effect in a DLL" +#endif + // Executables (but not DLLs) exporting this symbol with this value will be // automatically directed to the high-performance GPU on Nvidia Optimus systems // with up-to-date drivers From 291f6dc32c6d6359f56dd495374aea8291357b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 19 Mar 2021 14:24:50 +0100 Subject: [PATCH 25/26] Remove deprecated Doxygen tag Fixes #1867. --- docs/Doxyfile.in | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index c3682222..f5504a83 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -1074,13 +1074,6 @@ VERBATIM_HEADERS = YES ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored From 33cd8b865d9289cfbcf3d95e6e68e4050b94fcd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 19 Mar 2021 14:47:28 +0100 Subject: [PATCH 26/26] Add issue number to changelog Related to #1863. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9e4f2df9..26e88828 100644 --- a/README.md +++ b/README.md @@ -213,6 +213,7 @@ information on what to include when reporting a bug. - [X11] Bugfix: Keys pressed simultaneously with others were not always reported (#1112,#1415,#1472,#1616) - [X11] Bugfix: Some window attributes were not applied on leaving fullscreen + (#1863) - [Wayland] Removed support for `wl_shell` (#1443) - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432) - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled