From 0b2660f39fc7111a3ef2723b03f5111afbe75bb9 Mon Sep 17 00:00:00 2001 From: Nicolas Caramelli Date: Sat, 3 Oct 2020 22:22:32 +0200 Subject: [PATCH 01/26] Wayland: Remove FindWaylandProtocols.cmake and FindXKBCommon.cmake (not used anymore) --- CMake/modules/FindWaylandProtocols.cmake | 26 ------------------ CMake/modules/FindXKBCommon.cmake | 34 ------------------------ 2 files changed, 60 deletions(-) delete mode 100644 CMake/modules/FindWaylandProtocols.cmake delete mode 100644 CMake/modules/FindXKBCommon.cmake diff --git a/CMake/modules/FindWaylandProtocols.cmake b/CMake/modules/FindWaylandProtocols.cmake deleted file mode 100644 index 8eb83f27..00000000 --- a/CMake/modules/FindWaylandProtocols.cmake +++ /dev/null @@ -1,26 +0,0 @@ -find_package(PkgConfig) - -pkg_check_modules(WaylandProtocols QUIET wayland-protocols>=${WaylandProtocols_FIND_VERSION}) - -execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols - OUTPUT_VARIABLE WaylandProtocols_PKGDATADIR - RESULT_VARIABLE _pkgconfig_failed) -if (_pkgconfig_failed) - message(FATAL_ERROR "Missing wayland-protocols pkgdatadir") -endif() - -string(REGEX REPLACE "[\r\n]" "" WaylandProtocols_PKGDATADIR "${WaylandProtocols_PKGDATADIR}") - -find_package_handle_standard_args(WaylandProtocols - FOUND_VAR - WaylandProtocols_FOUND - REQUIRED_VARS - WaylandProtocols_PKGDATADIR - VERSION_VAR - WaylandProtocols_VERSION - HANDLE_COMPONENTS -) - -set(WAYLAND_PROTOCOLS_FOUND ${WaylandProtocols_FOUND}) -set(WAYLAND_PROTOCOLS_PKGDATADIR ${WaylandProtocols_PKGDATADIR}) -set(WAYLAND_PROTOCOLS_VERSION ${WaylandProtocols_VERSION}) diff --git a/CMake/modules/FindXKBCommon.cmake b/CMake/modules/FindXKBCommon.cmake deleted file mode 100644 index 0f571eea..00000000 --- a/CMake/modules/FindXKBCommon.cmake +++ /dev/null @@ -1,34 +0,0 @@ -# - Try to find XKBCommon -# Once done, this will define -# -# XKBCOMMON_FOUND - System has XKBCommon -# XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories -# XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon -# XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon - -find_package(PkgConfig) -pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon) -set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER}) - -find_path(XKBCOMMON_INCLUDE_DIR - NAMES xkbcommon/xkbcommon.h - HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS} -) - -find_library(XKBCOMMON_LIBRARY - NAMES xkbcommon - HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS} -) - -set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY}) -set(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS}) -set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(XKBCommon DEFAULT_MSG - XKBCOMMON_LIBRARY - XKBCOMMON_INCLUDE_DIR -) - -mark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR) - From 166611cef5967313e6a3d50849e57ddbcdc33f26 Mon Sep 17 00:00:00 2001 From: Doug Binks Date: Fri, 4 Sep 2020 16:59:08 +0100 Subject: [PATCH 02/26] Win32: Update all monitor handles on config change Closes #1761. --- src/win32_monitor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/win32_monitor.c b/src/win32_monitor.c index 5f91c579..b4c53e4c 100644 --- a/src/win32_monitor.c +++ b/src/win32_monitor.c @@ -185,6 +185,8 @@ void _glfwPollMonitorsWin32(void) display.DeviceName) == 0) { disconnected[i] = NULL; + // handle may have changed, update + EnumDisplayMonitors(NULL, NULL, monitorCallback, (LPARAM) _glfw.monitors[i]); break; } } From 60e7364b304e4ead20856db303c03ee7359a0097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 23 Sep 2020 23:34:42 +0200 Subject: [PATCH 03/26] Update changelog Related to #1761. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index cafcca46..ed94b27a 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,8 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Some synthetic key events were reported as `GLFW_KEY_UNKNOWN` (#1623) - [Win32] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16 + - [Win32] Bugfix: Monitor functions could return invalid values after + configuration change (#1761) - [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) From 53b1396a09be83254e90dc4c815052a1a57ab144 Mon Sep 17 00:00:00 2001 From: Vladimir Perminov Date: Tue, 29 Sep 2020 20:03:42 +0300 Subject: [PATCH 04/26] Win32: Fix value for _WIN32_WINNT_WINBLUE An incorrect value for _WIN32_WINNT_WINBLUE caused GLFW to think Windows 8 was 8.1 or greater. This led to a crash when attempting to call SetProcessDpiAwareness. Closes #1775. --- src/win32_platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/win32_platform.h b/src/win32_platform.h index 260a77ff..4f520514 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -102,7 +102,7 @@ #define DISPLAY_DEVICE_ACTIVE 0x00000001 #endif #ifndef _WIN32_WINNT_WINBLUE - #define _WIN32_WINNT_WINBLUE 0x0602 + #define _WIN32_WINNT_WINBLUE 0x0603 #endif #ifndef _WIN32_WINNT_WIN8 #define _WIN32_WINNT_WIN8 0x0602 From 48aa567d0c825cf2073f6a06d72f1aa593da7ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 29 Sep 2020 20:16:59 +0200 Subject: [PATCH 05/26] Update changelog and add credit Related to #1775. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ed94b27a..8383d594 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16 - [Win32] Bugfix: Monitor functions could return invalid values after configuration change (#1761) + - [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775) - [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) @@ -360,6 +361,7 @@ skills. - Braden Pellett - Christopher Pelloux - Arturo J. Pérez + - Vladimir Perminov - Anthony Pesch - Orson Peters - Emmanuel Gil Peyrot From 8d47dc5894623bc7a1447236fd9ba62ecd70bc97 Mon Sep 17 00:00:00 2001 From: Nicolas Caramelli Date: Sun, 4 Oct 2020 21:33:08 +0200 Subject: [PATCH 06/26] Update test SPIR-V shader code Closes #1781. --- tests/triangle-vulkan.c | 188 ++++++++++------------------------------ 1 file changed, 46 insertions(+), 142 deletions(-) diff --git a/tests/triangle-vulkan.c b/tests/triangle-vulkan.c index 33442968..7f783694 100644 --- a/tests/triangle-vulkan.c +++ b/tests/triangle-vulkan.c @@ -70,150 +70,54 @@ static GLADapiproc glad_vulkan_callback(const char* name, void* user) return glfwGetInstanceProcAddress((VkInstance) user, name); } -static const char fragShaderCode[] = { - 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00, - 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73, 0x65, 0x70, 0x61, 0x72, - 0x61, 0x74, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x6f, - 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x00, 0x00, 0x04, 0x00, 0x09, 0x00, - 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73, 0x68, 0x61, 0x64, 0x69, - 0x6e, 0x67, 0x5f, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x5f, - 0x34, 0x32, 0x30, 0x70, 0x61, 0x63, 0x6b, 0x00, 0x05, 0x00, 0x04, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x75, 0x46, 0x72, 0x61, - 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00, 0x05, 0x00, 0x05, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x0e, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x57, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x0e, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, - 0x38, 0x00, 0x01, 0x00 +static const uint32_t fragShaderCode[] = { + 0x07230203,0x00010000,0x00080007,0x00000014,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x00000011,0x00030010, + 0x00000004,0x00000007,0x00030003,0x00000002,0x00000190,0x00090004,0x415f4c47,0x735f4252, + 0x72617065,0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00090004,0x415f4c47, + 0x735f4252,0x69646168,0x6c5f676e,0x75676e61,0x5f656761,0x70303234,0x006b6361,0x00040005, + 0x00000004,0x6e69616d,0x00000000,0x00050005,0x00000009,0x61724675,0x6c6f4367,0x0000726f, + 0x00030005,0x0000000d,0x00786574,0x00050005,0x00000011,0x63786574,0x64726f6f,0x00000000, + 0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x00000022,0x00000000, + 0x00040047,0x0000000d,0x00000021,0x00000000,0x00040047,0x00000011,0x0000001e,0x00000000, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, + 0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003,0x00000007, + 0x0004003b,0x00000008,0x00000009,0x00000003,0x00090019,0x0000000a,0x00000006,0x00000001, + 0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x0000000b,0x0000000a, + 0x00040020,0x0000000c,0x00000000,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000000, + 0x00040017,0x0000000f,0x00000006,0x00000002,0x00040020,0x00000010,0x00000001,0x0000000f, + 0x0004003b,0x00000010,0x00000011,0x00000001,0x00050036,0x00000002,0x00000004,0x00000000, + 0x00000003,0x000200f8,0x00000005,0x0004003d,0x0000000b,0x0000000e,0x0000000d,0x0004003d, + 0x0000000f,0x00000012,0x00000011,0x00050057,0x00000007,0x00000013,0x0000000e,0x00000012, + 0x0003003e,0x00000009,0x00000013,0x000100fd,0x00010038 }; -static const char vertShaderCode[] = { - 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, - 0x04, 0x00, 0x09, 0x00, 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73, - 0x65, 0x70, 0x61, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x64, - 0x65, 0x72, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x00, 0x00, - 0x04, 0x00, 0x09, 0x00, 0x47, 0x4c, 0x5f, 0x41, 0x52, 0x42, 0x5f, 0x73, - 0x68, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x6c, 0x61, 0x6e, 0x67, 0x75, - 0x61, 0x67, 0x65, 0x5f, 0x34, 0x32, 0x30, 0x70, 0x61, 0x63, 0x6b, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72, - 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74, - 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x43, - 0x6c, 0x69, 0x70, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x00, - 0x05, 0x00, 0x05, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x56, - 0x65, 0x72, 0x74, 0x65, 0x78, 0x49, 0x44, 0x00, 0x05, 0x00, 0x06, 0x00, - 0x1d, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x49, 0x6e, 0x73, 0x74, 0x61, - 0x6e, 0x63, 0x65, 0x49, 0x44, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x15, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x1a, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, - 0x38, 0x00, 0x01, 0x00 +static const uint32_t vertShaderCode[] = { + 0x07230203,0x00010000,0x00080007,0x00000018,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, + 0x0009000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000b,0x00000010, + 0x00000014,0x00030003,0x00000002,0x00000190,0x00090004,0x415f4c47,0x735f4252,0x72617065, + 0x5f657461,0x64616873,0x6f5f7265,0x63656a62,0x00007374,0x00090004,0x415f4c47,0x735f4252, + 0x69646168,0x6c5f676e,0x75676e61,0x5f656761,0x70303234,0x006b6361,0x00040005,0x00000004, + 0x6e69616d,0x00000000,0x00050005,0x00000009,0x63786574,0x64726f6f,0x00000000,0x00040005, + 0x0000000b,0x72747461,0x00000000,0x00060005,0x0000000e,0x505f6c67,0x65567265,0x78657472, + 0x00000000,0x00060006,0x0000000e,0x00000000,0x505f6c67,0x7469736f,0x006e6f69,0x00030005, + 0x00000010,0x00000000,0x00030005,0x00000014,0x00736f70,0x00040047,0x00000009,0x0000001e, + 0x00000000,0x00040047,0x0000000b,0x0000001e,0x00000001,0x00050048,0x0000000e,0x00000000, + 0x0000000b,0x00000000,0x00030047,0x0000000e,0x00000002,0x00040047,0x00000014,0x0000001e, + 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006, + 0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000003, + 0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040020,0x0000000a,0x00000001, + 0x00000007,0x0004003b,0x0000000a,0x0000000b,0x00000001,0x00040017,0x0000000d,0x00000006, + 0x00000004,0x0003001e,0x0000000e,0x0000000d,0x00040020,0x0000000f,0x00000003,0x0000000e, + 0x0004003b,0x0000000f,0x00000010,0x00000003,0x00040015,0x00000011,0x00000020,0x00000001, + 0x0004002b,0x00000011,0x00000012,0x00000000,0x00040020,0x00000013,0x00000001,0x0000000d, + 0x0004003b,0x00000013,0x00000014,0x00000001,0x00040020,0x00000016,0x00000003,0x0000000d, + 0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003d, + 0x00000007,0x0000000c,0x0000000b,0x0003003e,0x00000009,0x0000000c,0x0004003d,0x0000000d, + 0x00000015,0x00000014,0x00050041,0x00000016,0x00000017,0x00000010,0x00000012,0x0003003e, + 0x00000017,0x00000015,0x000100fd,0x00010038 }; struct texture_object { From a506a8dc73dca2d3e07068d02cd008cdf958a914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 5 Oct 2020 23:23:57 +0200 Subject: [PATCH 07/26] Add credit Related to #1779 and #1781. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8383d594..7488e6d0 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,7 @@ skills. - Rok Breulj - Kai Burjack - Martin Capitanio + - Nicolas Caramelli - David Carlier - Arturo Castro - Chi-kwan Chan From 0ef149c8f2451fbc8e866834675a075cfc295b6c Mon Sep 17 00:00:00 2001 From: Nicolas Caramelli Date: Wed, 14 Oct 2020 10:25:46 +0200 Subject: [PATCH 08/26] Wayland: Assume 96 DPI if physical size is <= 0 --- src/wl_init.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/wl_init.c b/src/wl_init.c index 21a808aa..d3e777d4 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1038,6 +1038,8 @@ int _glfwPlatformInit(void) char *cursorSizeEnd; long cursorSizeLong; int cursorSize; + int i; + _GLFWmonitor* monitor; _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0"); if (!_glfw.wl.cursor.handle) @@ -1146,6 +1148,17 @@ int _glfwPlatformInit(void) // Sync so we got all initial output events wl_display_roundtrip(_glfw.wl.display); + for (i = 0; i < _glfw.monitorCount; ++i) + { + monitor = _glfw.monitors[i]; + if (monitor->widthMM <= 0 || monitor->heightMM <= 0) + { + // If Wayland does not provide a physical size, assume the default 96 DPI + monitor->widthMM = (int) (monitor->modes[monitor->wl.currentMode].width * 25.4f / 96.f); + monitor->heightMM = (int) (monitor->modes[monitor->wl.currentMode].height * 25.4f / 96.f); + } + } + _glfwInitTimerPOSIX(); _glfw.wl.timerfd = -1; From c940695eb03723fa6e4b174db524bcaa4f55bbee Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Wed, 14 Oct 2020 17:53:01 +0100 Subject: [PATCH 09/26] Fix macOS Print Screen Many years ago this value was changed from F13 to Print Screen with 1ae9ce1e0a00bf6f8b7e719bf1ec6e73f111afcf. However, this was later reverted to F13 with 5759d0fdf272351b35f666718a6e2a665db827e8. This changes it back to Print Screen for consistency with other platforms. Closes #1786. --- src/cocoa_init.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cocoa_init.m b/src/cocoa_init.m index 7cad8b8e..edd174be 100644 --- a/src/cocoa_init.m +++ b/src/cocoa_init.m @@ -251,7 +251,7 @@ static void createKeyTables(void) _glfw.ns.keycodes[0x6D] = GLFW_KEY_F10; _glfw.ns.keycodes[0x67] = GLFW_KEY_F11; _glfw.ns.keycodes[0x6F] = GLFW_KEY_F12; - _glfw.ns.keycodes[0x69] = GLFW_KEY_F13; + _glfw.ns.keycodes[0x69] = GLFW_KEY_PRINT_SCREEN; _glfw.ns.keycodes[0x6B] = GLFW_KEY_F14; _glfw.ns.keycodes[0x71] = GLFW_KEY_F15; _glfw.ns.keycodes[0x6A] = GLFW_KEY_F16; From 35f3508ecd5979ea456604b0ffc3aaeb85575587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 20 Oct 2020 20:03:58 +0200 Subject: [PATCH 10/26] Update changelog and add credit Related to #1786. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7488e6d0..a87b7f0b 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,8 @@ information on what to include when reporting a bug. - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle - [Cocoa] Moved main menu creation to GLFW initialization time (#1649) - [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169) + - [Cocoa] Changed F13 key to report Print Screen for cross-platform consistency + (#1786) - [Cocoa] Removed dependency on the CoreVideo framework - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553) - [Cocoa] Bugfix: Window remained on screen after destruction until event poll @@ -428,6 +430,7 @@ skills. - Waris - Jay Weisskopf - Frank Wille + - Andy Williams - Tatsuya Yatagawa - Ryogo Yoshimura - Lukas Zanner From 9b140d08d72b52915ddf1974342af06c6b93e06d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Oct 2020 21:40:16 +0200 Subject: [PATCH 11/26] Remove ignored Clang compiler flag Clang ignores this when C99 is enabled, while GCC does not. Removing the checks for Clang to hopefully avoid a false sense of security. --- src/CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b47b2354..e2b86412 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,18 +121,20 @@ if (APPLE) LANGUAGE C) endif() -if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR - "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR - "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") - - # Make GCC and Clang warn about declarations that VS 2010 and 2012 won't - # accept for all source files that VS will build +# 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") 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 win32_window.c wgl_context.c egl_context.c osmesa_context.c PROPERTIES COMPILE_FLAGS -Wdeclaration-after-statement) +endif() + +if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR + "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR + "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") # Enable a reasonable set of warnings (no, -Wextra is not reasonable) target_compile_options(glfw PRIVATE "-Wall") From 6b78419c9ae8d504e3b44adab51645d89c23108c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Oct 2020 22:50:54 +0200 Subject: [PATCH 12/26] Win32: Enable /W3 on VS for library sources /W3 is the default for new VS projects and the library builds cleanly with it on VS 2010-2019 so let's try to keep it that way. --- src/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2b86412..71653557 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -132,12 +132,14 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") COMPILE_FLAGS -Wdeclaration-after-statement) 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") - # Enable a reasonable set of warnings (no, -Wextra is not reasonable) target_compile_options(glfw PRIVATE "-Wall") +elseif (MSVC) + target_compile_options(glfw PRIVATE "/W3") endif() if (WIN32) From ac627706ef93362caf08bd3bf249656efd9151e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Oct 2020 22:51:58 +0200 Subject: [PATCH 13/26] Win32: Fix clang-cl interpreting -Wall as /Wall Unlike -Wall, VS /Wall really means all warnings. Closes #1780. --- README.md | 1 + src/CMakeLists.txt | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a87b7f0b..ab16fb1c 100644 --- a/README.md +++ b/README.md @@ -296,6 +296,7 @@ skills. - Eloi Marín Gratacós - Stefan Gustavson - Jonathan Hale + - hdf89shfdfs - Sylvain Hellegouarch - Matthew Henry - heromyth diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 71653557..68b8e9a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -137,7 +137,12 @@ if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") - target_compile_options(glfw PRIVATE "-Wall") + if ("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC") + # Tell Clang-CL that this is a Clang flag + target_compile_options(glfw PRIVATE "/clang:-Wall") + else() + target_compile_options(glfw PRIVATE "-Wall") + endif() elseif (MSVC) target_compile_options(glfw PRIVATE "/W3") endif() From 0bccc3852b903e690e77e66d2486fb33166e112d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 7 Oct 2020 23:35:17 +0200 Subject: [PATCH 14/26] Win32: Filter out duplicate size events This mirrors the filtering done on X11 and Cocoa. Possibly this should be done by shared code instead. Fixes #1610. --- README.md | 2 ++ src/win32_platform.h | 3 +++ src/win32_window.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab16fb1c..5d18e33f 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,7 @@ information on what to include when reporting a bug. - [Win32] Bugfix: Monitor functions could return invalid values after configuration change (#1761) - [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775) + - [Win32] Bugfix: Duplicate size events were not filtered (#1610) - [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) @@ -326,6 +327,7 @@ skills. - Shane Liesegang - Anders Lindqvist - Leon Linhart + - Marco Lizza - Eyal Lotem - Aaron Loucks - Luflosi diff --git a/src/win32_platform.h b/src/win32_platform.h index 4f520514..6c81d4b5 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -314,6 +314,9 @@ typedef struct _GLFWwindowWin32 GLFWbool scaleToMonitor; GLFWbool keymenu; + // Cached size used to filter out duplicate events + int width, height; + // The last received cursor position, regardless of source int lastCursorPosX, lastCursorPosY; // The last recevied high surrogate when decoding pairs of UTF-16 messages diff --git a/src/win32_window.c b/src/win32_window.c index 8cb50500..ce06d37c 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -961,6 +961,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_SIZE: { + const int width = LOWORD(lParam); + const int height = HIWORD(lParam); const GLFWbool iconified = wParam == SIZE_MINIMIZED; const GLFWbool maximized = wParam == SIZE_MAXIMIZED || (window->win32.maximized && @@ -975,8 +977,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (window->win32.maximized != maximized) _glfwInputWindowMaximize(window, maximized); - _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam)); - _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam)); + if (width != window->win32.width || height != window->win32.height) + { + window->win32.width = width; + window->win32.height = height; + + _glfwInputFramebufferSize(window, width, height); + _glfwInputWindowSize(window, width, height); + } if (window->monitor && window->win32.iconified != iconified) { @@ -1315,6 +1323,8 @@ static int createNativeWindow(_GLFWwindow* window, window->win32.transparent = GLFW_TRUE; } + _glfwPlatformGetWindowSize(window, &window->win32.width, &window->win32.height); + return GLFW_TRUE; } From af8f9713dd807968d0cbcca77fb63a210aaa8f65 Mon Sep 17 00:00:00 2001 From: Joel Winarske Date: Thu, 8 Oct 2020 14:58:06 -0700 Subject: [PATCH 15/26] Wayland: Fix CMake binary dir when built as subdir Regression introduced by 2747e47393cbca2d09db56223e735bd94b21e2eb. Related to #1782. --- src/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 68b8e9a3..f583d571 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,22 +66,22 @@ if (_GLFW_WAYLAND) set(GLFW_WAYLAND_PROTOCOL_SOURCES) wayland_generate( ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml - ${CMAKE_BINARY_DIR}/src/wayland-xdg-shell-client-protocol) + ${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol) wayland_generate( ${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml - ${CMAKE_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol) + ${GLFW_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol) wayland_generate( ${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml - ${CMAKE_BINARY_DIR}/src/wayland-viewporter-client-protocol) + ${GLFW_BINARY_DIR}/src/wayland-viewporter-client-protocol) wayland_generate( ${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml - ${CMAKE_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol) + ${GLFW_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol) wayland_generate( ${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml - ${CMAKE_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol) + ${GLFW_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol) wayland_generate( ${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml - ${CMAKE_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol) + ${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol) target_sources(glfw PRIVATE ${GLFW_WAYLAND_PROTOCOL_SOURCES}) endif() From a6f8cc9d4458272d890f63b1873ed42f8ada6822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 12 Oct 2020 17:34:46 +0200 Subject: [PATCH 16/26] Fix unquoted paths with variable references Whitespace is a field separator in CMake. --- src/CMakeLists.txt | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f583d571..8a11ef96 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,38 +50,38 @@ if (_GLFW_WAYLAND) pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir) macro(wayland_generate protocol_file output_file) - add_custom_command(OUTPUT ${output_file}.h - COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header - < ${protocol_file} > ${output_file}.h - DEPENDS ${protocol_file}) - list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES ${output_file}.h) + add_custom_command(OUTPUT "${output_file}.h" + COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header + < "${protocol_file}" > "${output_file}.h" + DEPENDS "${protocol_file}") + list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.h)" - add_custom_command(OUTPUT ${output_file}.c - COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code - < ${protocol_file} > ${output_file}.c - DEPENDS ${protocol_file}) - list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES ${output_file}.c) + add_custom_command(OUTPUT "${output_file}.c" + COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code + < "${protocol_file}" > "${output_file}.c" + DEPENDS "${protocol_file}") + list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.c") endmacro() set(GLFW_WAYLAND_PROTOCOL_SOURCES) wayland_generate( - ${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml - ${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol) + "${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml" + "${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol") wayland_generate( - ${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml - ${GLFW_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol) + "${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml" + "${GLFW_BINARY_DIR}/src/wayland-xdg-decoration-client-protocol") wayland_generate( - ${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml - ${GLFW_BINARY_DIR}/src/wayland-viewporter-client-protocol) + "${WAYLAND_PROTOCOLS_BASE}/stable/viewporter/viewporter.xml" + "${GLFW_BINARY_DIR}/src/wayland-viewporter-client-protocol") wayland_generate( - ${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml - ${GLFW_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol) + "${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml" + "${GLFW_BINARY_DIR}/src/wayland-relative-pointer-unstable-v1-client-protocol") wayland_generate( - ${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml - ${GLFW_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol) + "${WAYLAND_PROTOCOLS_BASE}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml" + "${GLFW_BINARY_DIR}/src/wayland-pointer-constraints-unstable-v1-client-protocol") wayland_generate( - ${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml - ${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol) + "${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" + "${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol") target_sources(glfw PRIVATE ${GLFW_WAYLAND_PROTOCOL_SOURCES}) endif() From d5f32dfb3b64ad9e0271363e4421d95c5b167054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 12 Oct 2020 18:20:53 +0200 Subject: [PATCH 17/26] Wayland: Ensure paths are passed on in quoted form --- src/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8a11ef96..a12b96c4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,13 +53,16 @@ if (_GLFW_WAYLAND) add_custom_command(OUTPUT "${output_file}.h" COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header < "${protocol_file}" > "${output_file}.h" - DEPENDS "${protocol_file}") + DEPENDS "${protocol_file}" + VERBATIM) list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.h)" add_custom_command(OUTPUT "${output_file}.c" COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code < "${protocol_file}" > "${output_file}.c" - DEPENDS "${protocol_file}") + DEPENDS "${protocol_file}" + VERBATIM) + list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.c") endmacro() From a62a6c5019d1124603b55cc335ab8071689191c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 12 Oct 2020 18:26:09 +0200 Subject: [PATCH 18/26] Wayland: Scanner tool has input and output args --- src/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a12b96c4..61e13146 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,15 +51,13 @@ if (_GLFW_WAYLAND) macro(wayland_generate protocol_file output_file) add_custom_command(OUTPUT "${output_file}.h" - COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header - < "${protocol_file}" > "${output_file}.h" + COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h" DEPENDS "${protocol_file}" VERBATIM) list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.h)" add_custom_command(OUTPUT "${output_file}.c" - COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code - < "${protocol_file}" > "${output_file}.c" + COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c" DEPENDS "${protocol_file}" VERBATIM) From 420b165bffb63aec762d69db0f6372a3f2375762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 12 Oct 2020 18:32:50 +0200 Subject: [PATCH 19/26] Wayland: Fix indentation --- src/CMakeLists.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 61e13146..7c095e67 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,18 +50,18 @@ if (_GLFW_WAYLAND) pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir) macro(wayland_generate protocol_file output_file) - add_custom_command(OUTPUT "${output_file}.h" - COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h" - DEPENDS "${protocol_file}" - VERBATIM) - list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.h)" + add_custom_command(OUTPUT "${output_file}.h" + COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h" + DEPENDS "${protocol_file}" + VERBATIM) + list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.h)" - add_custom_command(OUTPUT "${output_file}.c" - COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c" - DEPENDS "${protocol_file}" - VERBATIM) + add_custom_command(OUTPUT "${output_file}.c" + COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c" + DEPENDS "${protocol_file}" + VERBATIM) - list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.c") + list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.c") endmacro() set(GLFW_WAYLAND_PROTOCOL_SOURCES) From 2f76f70c766390019241954a6645219422113daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 12 Oct 2020 18:34:09 +0200 Subject: [PATCH 20/26] Wayland: Simplify adding of protocol sources --- src/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c095e67..14450938 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,17 +54,15 @@ if (_GLFW_WAYLAND) COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_file}" "${output_file}.h" DEPENDS "${protocol_file}" VERBATIM) - list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.h)" add_custom_command(OUTPUT "${output_file}.c" COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_file}" "${output_file}.c" DEPENDS "${protocol_file}" VERBATIM) - list(APPEND GLFW_WAYLAND_PROTOCOL_SOURCES "${output_file}.c") + target_sources(glfw PRIVATE "${output_file}.h" "${output_file}.c") endmacro() - set(GLFW_WAYLAND_PROTOCOL_SOURCES) wayland_generate( "${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml" "${GLFW_BINARY_DIR}/src/wayland-xdg-shell-client-protocol") @@ -83,8 +81,6 @@ if (_GLFW_WAYLAND) wayland_generate( "${WAYLAND_PROTOCOLS_BASE}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml" "${GLFW_BINARY_DIR}/src/wayland-idle-inhibit-unstable-v1-client-protocol") - - target_sources(glfw PRIVATE ${GLFW_WAYLAND_PROTOCOL_SOURCES}) endif() if (WIN32 AND BUILD_SHARED_LIBS) From 5c928ff4527240b5b24e6c37229e7b35008bcf46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 12 Oct 2020 18:56:25 +0200 Subject: [PATCH 21/26] Add credit Related to #1774 and #1782. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5d18e33f..43ab7c3c 100644 --- a/README.md +++ b/README.md @@ -434,6 +434,7 @@ skills. - Jay Weisskopf - Frank Wille - Andy Williams + - Joel Winarske - Tatsuya Yatagawa - Ryogo Yoshimura - Lukas Zanner From 3327050ca66ad34426a82c217c2d60ced61526b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 18 Oct 2020 19:34:23 +0200 Subject: [PATCH 22/26] Cocoa: Fix ObjC being built as C with CMake 3.19 CMake 3.19 adds -xc when the LANGUAGE file property is C, breaking our workaround for CMake 3.15 and earlier not understanding the .m suffix. Fixes #1787. --- README.md | 2 ++ src/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43ab7c3c..198063c3 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ information on what to include when reporting a bug. (#1635) - [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) - [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) @@ -322,6 +323,7 @@ skills. - Konstantin Käfer - Eric Larson - Francis Lecavalier + - Jong Won Lee - Robin Leffmann - Glenn Lewis - Shane Liesegang diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 14450938..3a45ea50 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,7 +112,7 @@ target_include_directories(glfw PRIVATE target_link_libraries(glfw PRIVATE Threads::Threads ${glfw_LIBRARIES}) # Workaround for CMake not knowing about .m files before version 3.16 -if (APPLE) +if ("${CMAKE_VERSION}" VERSION_LESS "3.16" AND APPLE) set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m cocoa_window.m nsgl_context.m PROPERTIES LANGUAGE C) From 0dc1005c853e9bdd00448ca1a3405858790a9fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20K=C3=B6nig?= Date: Wed, 28 Oct 2020 19:23:28 +0100 Subject: [PATCH 23/26] Wayland: Fix destroying CSDs in the correct order On Wayland we implement Client-Side Decorations if the compositors do not implement SSDs. In that case, the destructors of the surfaces were called in the wrong order, leading to a dereference of an already freed object. We need to first destroy the subsurface before destroying the parent surface. Related PR on kitty: https://github.com/kovidgoyal/kitty/pull/3066 Related issue on kitty: https://github.com/kovidgoyal/kitty/issues/3051 Closes #1798. --- README.md | 2 ++ src/wl_window.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 198063c3..c7a5caa9 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Retrieving partial framebuffer size would segfault - [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms (#1463) + - [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder - [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 @@ -445,6 +446,7 @@ skills. - Santi Zupancic - Jonas Ådahl - Lasse Öörni + - Leonard König - All the unmentioned and anonymous contributors in the GLFW community, for bug reports, patches, feedback, testing and encouragement diff --git a/src/wl_window.c b/src/wl_window.c index 7b315d70..8899a44b 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -246,10 +246,10 @@ static void createDecorations(_GLFWwindow* window) static void destroyDecoration(_GLFWdecorationWayland* decoration) { - if (decoration->surface) - wl_surface_destroy(decoration->surface); if (decoration->subsurface) wl_subsurface_destroy(decoration->subsurface); + if (decoration->surface) + wl_surface_destroy(decoration->surface); if (decoration->viewport) wp_viewport_destroy(decoration->viewport); decoration->surface = NULL; From 7e8da57094281c73a0be5669a4b79686b4917f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Thu, 19 Nov 2020 02:49:14 +0100 Subject: [PATCH 24/26] Add missing changelog issue number --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c7a5caa9..b4d798b9 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,7 @@ information on what to include when reporting a bug. - [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms (#1463) - [Wayland] Bugfix: Client-Side Decorations were destroyed in the wrong worder + (#1798) - [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 08e5a1706318e4fd32366a88d0778a9f545175af Mon Sep 17 00:00:00 2001 From: Luflosi Date: Thu, 23 Jul 2020 18:22:23 +0200 Subject: [PATCH 25/26] Use switch statement instead of if-else-chain for cursor shapes Closes #1739. --- src/cocoa_window.m | 66 +++++++++++++++++++------------ src/win32_window.c | 57 ++++++++++++++++----------- src/wl_window.c | 90 ++++++++++++++++++++++++------------------ src/x11_window.c | 97 ++++++++++++++++++++++++++++------------------ 4 files changed, 187 insertions(+), 123 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 81b22e2f..b618dccc 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1635,14 +1635,21 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) SEL cursorSelector = NULL; // HACK: Try to use a private message - if (shape == GLFW_RESIZE_EW_CURSOR) - cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor"); - else if (shape == GLFW_RESIZE_NS_CURSOR) - cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor"); - else if (shape == GLFW_RESIZE_NWSE_CURSOR) - cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor"); - else if (shape == GLFW_RESIZE_NESW_CURSOR) - cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor"); + switch (shape) + { + case GLFW_RESIZE_EW_CURSOR: + cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor"); + break; + case GLFW_RESIZE_NS_CURSOR: + cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor"); + break; + case GLFW_RESIZE_NWSE_CURSOR: + cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor"); + break; + case GLFW_RESIZE_NESW_CURSOR: + cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor"); + break; + } if (cursorSelector && [NSCursor respondsToSelector:cursorSelector]) { @@ -1653,22 +1660,33 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) if (!cursor->ns.object) { - 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]; + switch (shape) + { + case GLFW_ARROW_CURSOR: + cursor->ns.object = [NSCursor arrowCursor]; + break; + case GLFW_IBEAM_CURSOR: + cursor->ns.object = [NSCursor IBeamCursor]; + break; + case GLFW_CROSSHAIR_CURSOR: + cursor->ns.object = [NSCursor crosshairCursor]; + break; + case GLFW_POINTING_HAND_CURSOR: + cursor->ns.object = [NSCursor pointingHandCursor]; + break; + case GLFW_RESIZE_EW_CURSOR: + cursor->ns.object = [NSCursor resizeLeftRightCursor]; + break; + case GLFW_RESIZE_NS_CURSOR: + cursor->ns.object = [NSCursor resizeUpDownCursor]; + break; + case GLFW_RESIZE_ALL_CURSOR: + cursor->ns.object = [NSCursor closedHandCursor]; + break; + case GLFW_NOT_ALLOWED_CURSOR: + cursor->ns.object = [NSCursor operationNotAllowedCursor]; + break; + } } if (!cursor->ns.object) diff --git a/src/win32_window.c b/src/win32_window.c index ce06d37c..febafae4 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2123,30 +2123,41 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { int id = 0; - if (shape == GLFW_ARROW_CURSOR) - id = OCR_NORMAL; - else if (shape == GLFW_IBEAM_CURSOR) - id = OCR_IBEAM; - else if (shape == GLFW_CROSSHAIR_CURSOR) - id = OCR_CROSS; - else if (shape == GLFW_POINTING_HAND_CURSOR) - id = OCR_HAND; - else if (shape == GLFW_RESIZE_EW_CURSOR) - id = OCR_SIZEWE; - 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 + switch (shape) { - _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor"); - return GLFW_FALSE; + case GLFW_ARROW_CURSOR: + id = OCR_NORMAL; + break; + case GLFW_IBEAM_CURSOR: + id = OCR_IBEAM; + break; + case GLFW_CROSSHAIR_CURSOR: + id = OCR_CROSS; + break; + case GLFW_POINTING_HAND_CURSOR: + id = OCR_HAND; + break; + case GLFW_RESIZE_EW_CURSOR: + id = OCR_SIZEWE; + break; + case GLFW_RESIZE_NS_CURSOR: + id = OCR_SIZENS; + break; + case GLFW_RESIZE_NWSE_CURSOR: + id = OCR_SIZENWSE; + break; + case GLFW_RESIZE_NESW_CURSOR: + id = OCR_SIZENESW; + break; + case GLFW_RESIZE_ALL_CURSOR: + id = OCR_SIZEALL; + break; + case GLFW_NOT_ALLOWED_CURSOR: + id = OCR_NO; + break; + default: + _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor"); + return GLFW_FALSE; } cursor->win32.handle = LoadImageW(NULL, diff --git a/src/wl_window.c b/src/wl_window.c index 8899a44b..939f9c19 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1242,26 +1242,39 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) const char* name = NULL; // 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"; + switch (shape) + { + case GLFW_ARROW_CURSOR: + name = "default"; + break; + case GLFW_IBEAM_CURSOR: + name = "text"; + break; + case GLFW_CROSSHAIR_CURSOR: + name = "crosshair"; + break; + case GLFW_POINTING_HAND_CURSOR: + name = "pointer"; + break; + case GLFW_RESIZE_EW_CURSOR: + name = "ew-resize"; + break; + case GLFW_RESIZE_NS_CURSOR: + name = "ns-resize"; + break; + case GLFW_RESIZE_NWSE_CURSOR: + name = "nwse-resize"; + break; + case GLFW_RESIZE_NESW_CURSOR: + name = "nesw-resize"; + break; + case GLFW_RESIZE_ALL_CURSOR: + name = "all-scroll"; + break; + case GLFW_NOT_ALLOWED_CURSOR: + name = "not-allowed"; + break; + } cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); @@ -1274,25 +1287,26 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) 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 + switch (shape) { - _glfwInputError(GLFW_CURSOR_UNAVAILABLE, - "Wayland: Standard cursor shape unavailable"); - return GLFW_FALSE; + case GLFW_ARROW_CURSOR: + name = "left_ptr"; + case GLFW_IBEAM_CURSOR: + name = "xterm"; + case GLFW_CROSSHAIR_CURSOR: + name = "crosshair"; + case GLFW_POINTING_HAND_CURSOR: + name = "hand2"; + case GLFW_RESIZE_EW_CURSOR: + name = "sb_h_double_arrow"; + case GLFW_RESIZE_NS_CURSOR: + name = "sb_v_double_arrow"; + case GLFW_RESIZE_ALL_CURSOR: + name = "fleur"; + default: + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "Wayland: Standard cursor shape unavailable"); + return GLFW_FALSE; } cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); diff --git a/src/x11_window.c b/src/x11_window.c index 4cd32940..a85688e1 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -2935,26 +2935,39 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) const int size = XcursorGetDefaultSize(_glfw.x11.display); const char* name = NULL; - 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"; + switch (shape) + { + case GLFW_ARROW_CURSOR: + name = "default"; + break; + case GLFW_IBEAM_CURSOR: + name = "text"; + break; + case GLFW_CROSSHAIR_CURSOR: + name = "crosshair"; + break; + case GLFW_POINTING_HAND_CURSOR: + name = "pointer"; + break; + case GLFW_RESIZE_EW_CURSOR: + name = "ew-resize"; + break; + case GLFW_RESIZE_NS_CURSOR: + name = "ns-resize"; + break; + case GLFW_RESIZE_NWSE_CURSOR: + name = "nwse-resize"; + break; + case GLFW_RESIZE_NESW_CURSOR: + name = "nesw-resize"; + break; + case GLFW_RESIZE_ALL_CURSOR: + name = "all-scroll"; + break; + case GLFW_NOT_ALLOWED_CURSOR: + name = "not-allowed"; + break; + } XcursorImage* image = XcursorLibraryLoadImage(name, theme, size); if (image) @@ -2969,25 +2982,33 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) { 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 + switch (shape) { - _glfwInputError(GLFW_CURSOR_UNAVAILABLE, - "X11: Standard cursor shape unavailable"); - return GLFW_FALSE; + case GLFW_ARROW_CURSOR: + native = XC_left_ptr; + break; + case GLFW_IBEAM_CURSOR: + native = XC_xterm; + break; + case GLFW_CROSSHAIR_CURSOR: + native = XC_crosshair; + break; + case GLFW_POINTING_HAND_CURSOR: + native = XC_hand2; + break; + case GLFW_RESIZE_EW_CURSOR: + native = XC_sb_h_double_arrow; + break; + case GLFW_RESIZE_NS_CURSOR: + native = XC_sb_v_double_arrow; + break; + case GLFW_RESIZE_ALL_CURSOR: + native = XC_fleur; + break; + default: + _glfwInputError(GLFW_CURSOR_UNAVAILABLE, + "X11: Standard cursor shape unavailable"); + return GLFW_FALSE; } cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native); From 1adfbde4d7fb862bb36d4a20e05d16bf712170f3 Mon Sep 17 00:00:00 2001 From: Nicolas Caramelli Date: Mon, 19 Oct 2020 22:00:30 +0200 Subject: [PATCH 26/26] Wayland: Move 96 DPI default to outputHandleMode Closes #1792. --- src/wl_init.c | 13 ------------- src/wl_monitor.c | 9 +++++++++ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index d3e777d4..21a808aa 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -1038,8 +1038,6 @@ int _glfwPlatformInit(void) char *cursorSizeEnd; long cursorSizeLong; int cursorSize; - int i; - _GLFWmonitor* monitor; _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0"); if (!_glfw.wl.cursor.handle) @@ -1148,17 +1146,6 @@ int _glfwPlatformInit(void) // Sync so we got all initial output events wl_display_roundtrip(_glfw.wl.display); - for (i = 0; i < _glfw.monitorCount; ++i) - { - monitor = _glfw.monitors[i]; - if (monitor->widthMM <= 0 || monitor->heightMM <= 0) - { - // If Wayland does not provide a physical size, assume the default 96 DPI - monitor->widthMM = (int) (monitor->modes[monitor->wl.currentMode].width * 25.4f / 96.f); - monitor->heightMM = (int) (monitor->modes[monitor->wl.currentMode].height * 25.4f / 96.f); - } - } - _glfwInitTimerPOSIX(); _glfw.wl.timerfd = -1; diff --git a/src/wl_monitor.c b/src/wl_monitor.c index a6356de0..4cbfb51d 100644 --- a/src/wl_monitor.c +++ b/src/wl_monitor.c @@ -81,7 +81,16 @@ 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)