From f0dc7946a664861188fcd12f2a16d8426a7bcc82 Mon Sep 17 00:00:00 2001 From: Bernard Teo Date: Tue, 30 Jul 2024 23:31:54 +0800 Subject: [PATCH 1/4] Revert "fix: Building issues on Fedora" This reverts commit cf2e1890496773b46bef747fdce19c903d2e0d9f. --- lib/libimhex/source/helpers/fs.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index 60647d5c5b75e..7bee4a94cd12a 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -39,17 +39,18 @@ #if defined(OS_LINUX) #if GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4 #define GLFW_EXPOSE_NATIVE_X11 + #else + #define GLFW_EXPOSE_NATIVE_WAYLAND #endif #endif - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wunused-parameter" #include - #pragma GCC diagnostic pop #if defined(OS_LINUX) && GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4 #if GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4 #undef GLFW_EXPOSE_NATIVE_X11 + #else + #undef GLFW_EXPOSE_NATIVE_WAYLAND #endif #endif #if defined(OS_MACOS) From 2732f00195f8f25ff573ae3d4cf63506af041a94 Mon Sep 17 00:00:00 2001 From: Bernard Teo Date: Tue, 30 Jul 2024 23:32:13 +0800 Subject: [PATCH 2/4] Revert "fix: Allow ImHex to build under wayland again" This reverts commit 48fc1a7a1e90fb596662c4d59449aa011daefade. --- lib/libimhex/source/helpers/fs.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index 7bee4a94cd12a..36fd3ba9fe324 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -23,7 +23,6 @@ #if defined(OS_WEB) #include #else - #include #include #if defined(OS_WINDOWS) #define GLFW_EXPOSE_NATIVE_WIN32 @@ -37,21 +36,17 @@ #define GLFW_EXPOSE_NATIVE_COCOA #endif #if defined(OS_LINUX) - #if GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4 - #define GLFW_EXPOSE_NATIVE_X11 - #else - #define GLFW_EXPOSE_NATIVE_WAYLAND - #endif + #define GLFW_EXPOSE_NATIVE_X11 + #endif + #if defined(OS_LINUX) && defined(GLFW_WAYLAND_APP_ID) + #define GLFW_EXPOSE_NATIVE_WAYLAND #endif - #include - - #if defined(OS_LINUX) && GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4 - #if GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4 - #undef GLFW_EXPOSE_NATIVE_X11 - #else - #undef GLFW_EXPOSE_NATIVE_WAYLAND - #endif + #if defined(OS_LINUX) && defined(GLFW_WAYLAND_APP_ID) + #undef GLFW_EXPOSE_NATIVE_WAYLAND + #endif + #if defined(OS_LINUX) + #undef GLFW_EXPOSE_NATIVE_X11 #endif #if defined(OS_MACOS) #undef GLFW_EXPOSE_NATIVE_COCOA From 1e54fc74085e02f0cf3ce93a8282e15fa074dda5 Mon Sep 17 00:00:00 2001 From: Bernard Teo Date: Tue, 30 Jul 2024 23:49:14 +0800 Subject: [PATCH 3/4] fix: Properly fix GLFW Linux backend detection --- lib/libimhex/CMakeLists.txt | 27 +++++++++++++++++++++++++++ lib/libimhex/source/helpers/fs.cpp | 8 ++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index abcd9677faa54..faaac63fd3daa 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -80,6 +80,33 @@ else() target_compile_definitions(libimhex PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}") endif() +if (UNIX AND NOT APPLE) + # For Linux, we need to figure out whether our GLFW is built for X11, Wayland, or both + INCLUDE(CheckCXXSourceCompiles) + set(CMAKE_REQUIRED_INCLUDES ${GLFW_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES ${GLFW_LIBRARIES}) + check_cxx_source_compiles(" + #define GLFW_EXPOSE_NATIVE_X11 + #include + #include + Window test(GLFWwindow* w) { return glfwGetX11Window(w); } + int main() {} + " GLFW_HAS_X11) + check_cxx_source_compiles(" + #define GLFW_EXPOSE_NATIVE_WAYLAND + #include + #include + wl_surface* test(GLFWwindow* w) { return glfwGetWaylandWindow(w); } + int main() {} + " GLFW_HAS_WAYLAND) + if (GLFW_HAS_X11) + target_compile_definitions(libimhex PRIVATE GLFW_BACKEND_X11) + endif() + if (GLFW_HAS_WAYLAND) + target_compile_definitions(libimhex PRIVATE GLFW_BACKEND_WAYLAND) + endif() +endif() + if (DEFINED IMHEX_COMMIT_HASH_LONG AND DEFINED IMHEX_COMMIT_BRANCH) set(GIT_COMMIT_HASH_LONG "${IMHEX_COMMIT_HASH_LONG}") diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index 36fd3ba9fe324..69cd877c23fad 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -35,17 +35,17 @@ typedef void NSWindow; #define GLFW_EXPOSE_NATIVE_COCOA #endif - #if defined(OS_LINUX) + #if defined(OS_LINUX) && defined(GLFW_BACKEND_X11) #define GLFW_EXPOSE_NATIVE_X11 #endif - #if defined(OS_LINUX) && defined(GLFW_WAYLAND_APP_ID) + #if defined(OS_LINUX) && defined(GLFW_BACKEND_WAYLAND) #define GLFW_EXPOSE_NATIVE_WAYLAND #endif #include - #if defined(OS_LINUX) && defined(GLFW_WAYLAND_APP_ID) + #if defined(OS_LINUX) && defined(GLFW_BACKEND_WAYLAND) #undef GLFW_EXPOSE_NATIVE_WAYLAND #endif - #if defined(OS_LINUX) + #if defined(OS_LINUX) && defined(GLFW_BACKEND_X11) #undef GLFW_EXPOSE_NATIVE_X11 #endif #if defined(OS_MACOS) From 66d0ad980a2dfdebd988b8dd2cecb3591593a8d9 Mon Sep 17 00:00:00 2001 From: Bernard Teo Date: Sun, 28 Jul 2024 20:50:32 +0800 Subject: [PATCH 4/4] build: Testing fixed nativefiledialog --- lib/third_party/nativefiledialog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/third_party/nativefiledialog b/lib/third_party/nativefiledialog index c099aaee9a24a..ef6afbbe6137b 160000 --- a/lib/third_party/nativefiledialog +++ b/lib/third_party/nativefiledialog @@ -1 +1 @@ -Subproject commit c099aaee9a24a35ad93e06513b41aeb503d848d0 +Subproject commit ef6afbbe6137b5fe7e1603e2c88c2709a09873c1