diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp index 4579aeffb1de..bc18cf33c8f5 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_Unity.cpp @@ -273,7 +273,6 @@ class UnityPeer final : public ComponentPeer, //============================================================================== void setMinimised (bool) override {} bool isMinimised() const override { return false; } - bool isShowing() const override { return true; } void setFullScreen (bool) override {} bool isFullScreen() const override { return false; } bool setAlwaysOnTop (bool) override { return false; } diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index 5baac327b31e..656cb6d7ea69 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -158,7 +158,9 @@ void MidiKeyboardComponent::updateNoteUnderMouse (Point pos, bool isDown, const auto newNote = noteInfo.note; const auto oldNote = mouseOverNotes.getUnchecked (fingerNum); const auto oldNoteDown = mouseDownNotes.getUnchecked (fingerNum); - const auto eventVelocity = useMousePositionForVelocity ? noteInfo.velocity * velocity : velocity; + // SURGE PATCH: Don't double scale velocity + const auto eventVelocity = useMousePositionForVelocity ? noteInfo.velocity /* * velocity */ : velocity; + // END SURGE PATCH if (oldNote != newNote) { diff --git a/modules/juce_core/javascript/choc/containers/choc_Value.h b/modules/juce_core/javascript/choc/containers/choc_Value.h index 101b212f9de2..9649ac1345b8 100644 --- a/modules/juce_core/javascript/choc/containers/choc_Value.h +++ b/modules/juce_core/javascript/choc/containers/choc_Value.h @@ -2838,7 +2838,7 @@ inline void Value::changeMember (uint32_t index, const Type& newType, void* newD for (uint32_t i = 0; i < numElements; ++i) { - auto member = value.type.getObjectMember (i); + const auto &member = value.type.getObjectMember (i); newCopy.addMember (member.name, i == index ? ValueView (newType, newData, newDictionary) : value[i]); } diff --git a/modules/juce_core/javascript/choc/javascript/choc_javascript_QuickJS.h b/modules/juce_core/javascript/choc/javascript/choc_javascript_QuickJS.h index 12e93f8771de..a23894849d44 100644 --- a/modules/juce_core/javascript/choc/javascript/choc_javascript_QuickJS.h +++ b/modules/juce_core/javascript/choc/javascript/choc_javascript_QuickJS.h @@ -6023,8 +6023,8 @@ static int compute_stack_size(const uint8_t *bc_buf, int bc_buf_len) pos = 0; while (pos < bc_buf_len) { opcode = bc_buf[pos]; - len = reopcode_info[opcode].size; assert(opcode < REOP_COUNT); + len = reopcode_info[opcode].size; assert((pos + len) <= bc_buf_len); switch(opcode) { case REOP_push_i32: diff --git a/modules/juce_core/juce_core.cpp b/modules/juce_core/juce_core.cpp index a61a55d0d29e..ddff37f289c8 100644 --- a/modules/juce_core/juce_core.cpp +++ b/modules/juce_core/juce_core.cpp @@ -79,6 +79,7 @@ #endif #if JUCE_WASM + #include #include #include #include @@ -108,7 +109,7 @@ #include #include - #if ! (JUCE_ANDROID || JUCE_WASM) + #if ! (JUCE_ANDROID || JUCE_WASM || JUCE_MUSL) #include #endif #endif diff --git a/modules/juce_core/native/juce_SharedCode_posix.h b/modules/juce_core/native/juce_SharedCode_posix.h index c53ef0fff6f3..ba9f4c5e8f8b 100644 --- a/modules/juce_core/native/juce_SharedCode_posix.h +++ b/modules/juce_core/native/juce_SharedCode_posix.h @@ -178,7 +178,7 @@ inline int juce_siginterrupt ([[maybe_unused]] int sig, [[maybe_unused]] int fla //============================================================================== namespace { - #if JUCE_LINUX || (JUCE_IOS && (! TARGET_OS_MACCATALYST) && (! __DARWIN_ONLY_64_BIT_INO_T)) // (this iOS stuff is to avoid a simulator bug) + #if JUCE_GLIBC || (JUCE_IOS && (! TARGET_OS_MACCATALYST) && (! __DARWIN_ONLY_64_BIT_INO_T)) // (this iOS stuff is to avoid a simulator bug) using juce_statStruct = struct stat64; #define JUCE_STAT stat64 #else diff --git a/modules/juce_core/native/juce_SystemStats_linux.cpp b/modules/juce_core/native/juce_SystemStats_linux.cpp index 3d6bebc74c9a..6a21c6fbd56f 100644 --- a/modules/juce_core/native/juce_SystemStats_linux.cpp +++ b/modules/juce_core/native/juce_SystemStats_linux.cpp @@ -210,22 +210,22 @@ String SystemStats::getComputerName() String SystemStats::getUserLanguage() { - #if JUCE_BSD + #if JUCE_GLIBC + return getLocaleValue (_NL_ADDRESS_LANG_AB); + #else if (auto langEnv = getenv ("LANG")) return String::fromUTF8 (langEnv).upToLastOccurrenceOf (".UTF-8", false, true); return {}; - #else - return getLocaleValue (_NL_ADDRESS_LANG_AB); #endif } String SystemStats::getUserRegion() { - #if JUCE_BSD - return {}; - #else + #if JUCE_GLIBC return getLocaleValue (_NL_ADDRESS_COUNTRY_AB2); + #else + return {}; #endif } diff --git a/modules/juce_core/system/juce_SystemStats.cpp b/modules/juce_core/system/juce_SystemStats.cpp index 6dafa07185f6..f44bb8f8a053 100644 --- a/modules/juce_core/system/juce_SystemStats.cpp +++ b/modules/juce_core/system/juce_SystemStats.cpp @@ -190,7 +190,7 @@ String SystemStats::getStackBacktrace() { String result; - #if JUCE_ANDROID || JUCE_WASM + #if JUCE_ANDROID || JUCE_MINGW || JUCE_WASM || JUCE_MUSL jassertfalse; // sorry, not implemented yet! #elif JUCE_WINDOWS diff --git a/modules/juce_core/system/juce_TargetPlatform.h b/modules/juce_core/system/juce_TargetPlatform.h index 9b3b495f83f5..09b5c1f92f35 100644 --- a/modules/juce_core/system/juce_TargetPlatform.h +++ b/modules/juce_core/system/juce_TargetPlatform.h @@ -45,6 +45,7 @@ - Either JUCE_LITTLE_ENDIAN or JUCE_BIG_ENDIAN. - Either JUCE_INTEL or JUCE_ARM - Either JUCE_GCC or JUCE_CLANG or JUCE_MSVC + - Either JUCE_GLIBC or JUCE_MUSL will be defined on Linux depending on the system's libc implementation. */ //============================================================================== @@ -76,6 +77,8 @@ #define JUCE_ANDROID 1 #elif defined (__FreeBSD__) || defined (__OpenBSD__) #define JUCE_BSD 1 +#elif defined (__wasm__) + #define JUCE_WASM 1 #elif defined (LINUX) || defined (__linux__) #define JUCE_LINUX 1 #elif defined (__APPLE_CPP__) || defined (__APPLE_CC__) @@ -89,8 +92,6 @@ #else #define JUCE_MAC 1 #endif -#elif defined (__wasm__) - #define JUCE_WASM 1 #else #error "Unknown platform!" #endif @@ -196,6 +197,14 @@ #elif __MMX__ || __SSE__ || __amd64__ #define JUCE_INTEL 1 #endif + + #if JUCE_LINUX + #ifdef __GLIBC__ + #define JUCE_GLIBC 1 + #else + #define JUCE_MUSL 1 + #endif + #endif #endif //============================================================================== diff --git a/modules/juce_dsp/juce_dsp.cpp b/modules/juce_dsp/juce_dsp.cpp index bbd0e8f4ead0..21338f55f7cc 100644 --- a/modules/juce_dsp/juce_dsp.cpp +++ b/modules/juce_dsp/juce_dsp.cpp @@ -88,7 +88,9 @@ #include "widgets/juce_Chorus.cpp" #if JUCE_USE_SIMD - #if JUCE_INTEL + #if JUCE_INTEL || defined(__riscv) || defined(__EMSCRIPTEN__) + // falkTX patch to 6.* was this so ... add those ORs above + // #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) || defined(__riscv) || defined(__EMSCRIPTEN__) #ifdef __AVX2__ #include "native/juce_SIMDNativeOps_avx.cpp" #else diff --git a/modules/juce_dsp/juce_dsp.h b/modules/juce_dsp/juce_dsp.h index c51eba460d8d..9868f5ca8cd3 100644 --- a/modules/juce_dsp/juce_dsp.h +++ b/modules/juce_dsp/juce_dsp.h @@ -67,7 +67,7 @@ #include #include -#if defined (_M_X64) || defined (__amd64__) || defined (__SSE2__) || (defined (_M_IX86_FP) && _M_IX86_FP == 2) +#if defined(_M_X64) || defined(__amd64__) || defined(__SSE2__) || (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__riscv) || defined(__EMSCRIPTEN__) #if defined (_M_X64) || defined (__amd64__) #ifndef __SSE2__ @@ -234,7 +234,7 @@ namespace util #include "native/juce_SIMDNativeOps_fallback.h" // include the correct native file for this build target CPU - #if defined (__i386__) || defined (__amd64__) || defined (_M_X64) || defined (_X86_) || defined (_M_IX86) + #if defined(__i386__) || defined(__amd64__) || defined(_M_X64) || defined(_X86_) || defined(_M_IX86) || defined(__riscv) || defined(__EMSCRIPTEN__) #ifdef __AVX2__ #include "native/juce_SIMDNativeOps_avx.h" #else diff --git a/modules/juce_graphics/fonts/harfbuzz/hb-directwrite.cc b/modules/juce_graphics/fonts/harfbuzz/hb-directwrite.cc index 6c90265d0b6e..d4cacf4c8609 100644 --- a/modules/juce_graphics/fonts/harfbuzz/hb-directwrite.cc +++ b/modules/juce_graphics/fonts/harfbuzz/hb-directwrite.cc @@ -168,8 +168,11 @@ _hb_directwrite_shaper_face_data_create (hb_face_t *face) } HB_STMT_END data->dwrite_dll = LoadLibrary (TEXT ("DWRITE")); - if (unlikely (!data->dwrite_dll)) - FAIL ("Cannot find DWrite.DLL"); + if ( unlikely( !data->dwrite_dll ) ) + { + delete data; + FAIL("Cannot find DWrite.DLL"); + } t_DWriteCreateFactory p_DWriteCreateFactory; diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index f0e7723bc4e3..1db194712977 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -343,7 +343,7 @@ bool Component::isShowing() const return parentComponent->isShowing(); if (auto* peer = getPeer()) - return peer->isShowing(); + return ! peer->isMinimised(); return false; } diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 1118a6e103f7..e306a7ef3de1 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -32,6 +32,8 @@ ============================================================================== */ +// clang-format off + namespace juce { @@ -190,7 +192,9 @@ struct ItemComponent final : public Component static bool isAccessibilityHandlerRequired (const PopupMenu::Item& item) { - return item.isSectionHeader || hasActiveSubMenu (item) || canBeTriggered (item); + return item.isSectionHeader || hasActiveSubMenu (item) || canBeTriggered (item) || + // SURGE FIX : if the custom component is accessible! + (item.customComponent != nullptr && item.customComponent->isAccessible()); } PopupMenu::Item item; @@ -211,7 +215,13 @@ struct ItemComponent final : public Component String getTitle() const override { - return itemComponent.item.text; + auto res = itemComponent.item.text + (itemComponent.item.isTicked ? " (Checked)" : ""); +#if JUCE_MAC + if (hasActiveSubMenu(itemComponent.item)) + res += " (has SubMenu)"; +#endif + + return res; } AccessibleState getCurrentState() const override @@ -645,12 +655,43 @@ struct MenuWindow final : public Component } else if (key.isKeyCode (KeyPress::returnKey) || key.isKeyCode (KeyPress::spaceKey)) { - triggerCurrentlyHighlightedItem(); + // SURGE FIX: Use 'return key' to open submenus + if (showSubMenuFor (currentChild)) + { + if (isSubMenuVisible()) + activeSubMenu->selectNextItem (MenuSelectionDirection::current); + } + // END SURGE FIX: + else + { + // SURGE FIX : if I have a custom component try its keyPressed + if (currentChild && currentChild->item.customComponent != nullptr) + { + if (currentChild->item.customComponent->keyPressed(key)) + { + } + else + { + triggerCurrentlyHighlightedItem(); + } + } + // END SURGE FIX + else + { + triggerCurrentlyHighlightedItem(); + } + } } else if (key.isKeyCode (KeyPress::escapeKey)) { dismissMenu (nullptr); } + // surge patch to work around reaper issue described in #7281 + else if (key.isKeyCode(KeyPress::F10Key) && key.getModifiers().isShiftDown()) + { + dismissMenu (nullptr); + } + // end surge patch else { return false; @@ -1258,7 +1299,12 @@ struct MenuWindow final : public Component if (auto* mic = items.getUnchecked ((start + items.size()) % items.size())) { - if (canBeTriggered (mic->item) || hasActiveSubMenu (mic->item)) + if (canBeTriggered (mic->item) || hasActiveSubMenu (mic->item) || + // SURGE FIX: You can select accessible menu custom components + (mic->item.customComponent != nullptr && + mic->item.customComponent->isAccessible()) + // END SURGE FIX + ) { setCurrentlyHighlightedChild (mic); return; diff --git a/modules/juce_gui_basics/native/accessibility/juce_UIAHelpers_windows.h b/modules/juce_gui_basics/native/accessibility/juce_UIAHelpers_windows.h index 8dd172104f64..1c014d697949 100644 --- a/modules/juce_gui_basics/native/accessibility/juce_UIAHelpers_windows.h +++ b/modules/juce_gui_basics/native/accessibility/juce_UIAHelpers_windows.h @@ -87,7 +87,7 @@ inline JUCE_COMRESULT addHandlersToArray (const std::vector (rangeProvider)); - - if (FAILED (hr)) - return E_FAIL; + hr = SafeArrayPutElement (*pRetVal, &pos, static_cast (rangeProvider)); rangeProvider->Release(); } + else + { + hr = E_FAIL; + } - return S_OK; + return hr; }); } @@ -111,22 +114,25 @@ class UIATextProvider : public UIAProviderBase, { return withTextInterface (pRetVal, [&] (const AccessibilityTextInterface& textInterface) { - *pRetVal = SafeArrayCreateVector (VT_UNKNOWN, 0, 1); + HRESULT hr; - if (pRetVal != nullptr) + *pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, 1); + + if (*pRetVal != nullptr) { auto* rangeProvider = new UIATextRangeProvider (*this, { 0, textInterface.getTotalNumCharacters() }); LONG pos = 0; - auto hr = SafeArrayPutElement (*pRetVal, &pos, static_cast (rangeProvider)); - - if (FAILED (hr)) - return E_FAIL; + hr = SafeArrayPutElement (*pRetVal, &pos, static_cast (rangeProvider)); rangeProvider->Release(); } + else + { + hr = E_FAIL; + } - return S_OK; + return hr; }); } diff --git a/modules/juce_gui_basics/native/juce_FileChooser_windows.cpp b/modules/juce_gui_basics/native/juce_FileChooser_windows.cpp index 0801b061d343..8aeaeeb00f6a 100644 --- a/modules/juce_gui_basics/native/juce_FileChooser_windows.cpp +++ b/modules/juce_gui_basics/native/juce_FileChooser_windows.cpp @@ -451,25 +451,28 @@ class Win32NativeFileChooser final : private Thread LPITEMIDLIST list = SHBrowseForFolder (&bi); - if (! SHGetPathFromIDListW (list, files)) + if ( list != nullptr ) { - files[0] = 0; - returnedString.clear(); - } + if (!SHGetPathFromIDListW(list, files)) + { + files[0] = 0; + returnedString.clear(); + } - LPMALLOC al; + LPMALLOC al; - if (list != nullptr && SUCCEEDED (SHGetMalloc (&al))) - al->Free (list); + if (SUCCEEDED(SHGetMalloc(&al))) + al->Free(list); - if (files[0] != 0) - { - File result (String (files.get())); + if (files[0] != 0) + { + File result(String(files.get())); - if (returnedString.isNotEmpty()) - result = result.getSiblingFile (returnedString); + if (returnedString.isNotEmpty()) + result = result.getSiblingFile(returnedString); - selections.add (URL (result)); + selections.add(URL(result)); + } } } else diff --git a/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm b/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm index ed9cd36b1bff..ae12c1d915f1 100644 --- a/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm +++ b/modules/juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm @@ -465,11 +465,6 @@ bool isMinimised() const override return [window isMiniaturized]; } - bool isShowing() const override - { - return [window isVisible] && ! isMinimised(); - } - NSWindowCollectionBehavior getCollectionBehavior (bool forceFullScreen) const { if (forceFullScreen) diff --git a/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm b/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm index 1e0b0b073e43..caa9a9bb6949 100644 --- a/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm +++ b/modules/juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm @@ -408,7 +408,6 @@ void setViewController (UIViewController* newController) override void setAlpha (float newAlpha) override; void setMinimised (bool) override {} bool isMinimised() const override { return false; } - bool isShowing() const override { return true; } void setFullScreen (bool shouldBeFullScreen) override; bool isFullScreen() const override { return fullScreen; } bool contains (Point localPos, bool trueIfInAChildWindow) const override; diff --git a/modules/juce_gui_basics/native/juce_Windowing_android.cpp b/modules/juce_gui_basics/native/juce_Windowing_android.cpp index 2da8fa6f36d0..5deb88b15c04 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_android.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_android.cpp @@ -1462,11 +1462,6 @@ class AndroidComponentPeer final : public ComponentPeer, return false; } - bool isShowing() const override - { - return true; - } - void setFullScreen (bool shouldBeFullScreen) override { if (shouldNavBarsBeHidden (shouldBeFullScreen)) diff --git a/modules/juce_gui_basics/native/juce_Windowing_linux.cpp b/modules/juce_gui_basics/native/juce_Windowing_linux.cpp index 599ac5e8117d..51d0e34e14fa 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_linux.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_linux.cpp @@ -204,11 +204,6 @@ class LinuxComponentPeer final : public ComponentPeer, return XWindowSystem::getInstance()->isMinimised (windowH); } - bool isShowing() const override - { - return XWindowSystem::getInstance()->isMinimised (windowH); - } - void setFullScreen (bool shouldBeFullScreen) override { auto r = lastNonFullscreenBounds; // (get a copy of this before de-minimising) diff --git a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp index def48bfb7d84..f1233f3d01a0 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp @@ -1720,11 +1720,6 @@ class HWNDComponentPeer final : public ComponentPeer return wp.showCmd == SW_SHOWMINIMIZED; } - bool isShowing() const override - { - return IsWindowVisible (hwnd) && ! isMinimised(); - } - void setFullScreen (bool shouldBeFullScreen) override { const ScopedValueSetter scope (shouldIgnoreModalDismiss, true); @@ -1793,8 +1788,9 @@ class HWNDComponentPeer final : public ComponentPeer const auto screenPos = convertLogicalScreenPointToPhysical (localPos + getScreenPosition(), hwnd); - if (trueIfInAChildWindow) - return getClientRectInScreen().contains (screenPos); + // Surge diff while waiting for 803 revert + // if (trueIfInAChildWindow) + // return getClientRectInScreen().contains (screenPos); auto w = WindowFromPoint (D2DUtilities::toPOINT (screenPos)); diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.h b/modules/juce_gui_basics/windows/juce_ComponentPeer.h index b39b604a965f..2b4732a6834c 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.h +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.h @@ -244,9 +244,6 @@ class JUCE_API ComponentPeer : private FocusChangeListener /** True if the window is currently minimised. */ virtual bool isMinimised() const = 0; - /** True if the window is being displayed on-screen. */ - virtual bool isShowing() const = 0; - /** Enable/disable fullscreen mode for the window. */ virtual void setFullScreen (bool shouldBeFullScreen) = 0; diff --git a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp index 3e07d8a9889e..f3247043f91d 100644 --- a/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp +++ b/modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp @@ -190,6 +190,10 @@ struct LuaTokeniserFunctions case '?': case '~': + // SURGE ADDITION + case '#': + case '/': + // END SURGE ADDITION source.skip(); return LuaTokeniser::tokenType_operator;