diff --git a/CMakeLists.txt b/CMakeLists.txt index 11bf00be7..a749acd37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,6 +136,7 @@ option(WITH_INSTRUMENTS "Install instruments" ON) option(WITH_WAVETABLES "Install wavetables" ON) option(SHOW_OPEN_ASSETS_MENU_ENTRY "Show option to open built-in assets directory (on supported platforms)" OFF) option(CONSOLE_SUBSYSTEM "Build Furnace with Console subsystem on Windows" OFF) +option(FLATPAK_WORKAROUNDS "Enable Flatpak-specific workaround for system file picker" OFF) if (APPLE) option(FORCE_APPLE_BIN "Force enable binary installation to /bin" OFF) option(MAKE_BUNDLE "Make a bundle" OFF) @@ -159,6 +160,10 @@ if (IS_BIG_ENDIAN) list(APPEND DEPENDENCIES_DEFINES "TA_BIG_ENDIAN") endif() +if (FLATPAK_WORKAROUNDS) + list(APPEND DEPENDENCIES_DEFINES "FLATPAK_WORKAROUNDS") +endif() + set(DEPENDENCIES_COMPILE_OPTIONS "") set(DEPENDENCIES_LIBRARIES "") set(DEPENDENCIES_LIBRARY_DIRS "") diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 081dc04d7..c3b35f387 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2855,24 +2855,6 @@ void FurnaceGUI::processDrags(int dragX, int dragY) { fileName+=x; \ } -#define checkExtensionDual(x,y,fallback) \ - String lowerCase=fileName; \ - for (char& i: lowerCase) { \ - if (i>='A' && i<='Z') i+='a'-'A'; \ - } \ - if (lowerCase.size()<4 || (lowerCase.rfind(x)!=lowerCase.size()-4 && lowerCase.rfind(y)!=lowerCase.size()-4)) { \ - fileName+=fallback; \ - } - -#define checkExtensionTriple(x,y,z,fallback) \ - String lowerCase=fileName; \ - for (char& i: lowerCase) { \ - if (i>='A' && i<='Z') i+='a'-'A'; \ - } \ - if (lowerCase.size()<4 || (lowerCase.rfind(x)!=lowerCase.size()-4 && lowerCase.rfind(y)!=lowerCase.size()-4 && lowerCase.rfind(z)!=lowerCase.size()-4)) { \ - fileName+=fallback; \ - } - #define drawOpMask(m) \ ImGui::PushFont(patFont); \ ImGui::PushID("om_" #m); \ @@ -5146,7 +5128,13 @@ bool FurnaceGUI::loop() { } else { fileName=fileDialog->getFileName()[0]; } +#ifdef FLATPAK_WORKAROUNDS + // https://github.com/tildearrow/furnace/issues/2096 + // Flatpak Portals mangling our path hinders us from adding extension + if (fileName!="" && !settings.sysFileDialog) { +#else if (fileName!="") { +#endif if (curFileDialog==GUI_FILE_SAVE) { checkExtension(".fur"); }