From e9b8fb8bb4ac316f69141fd54ca92afd6ba66372 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Tue, 24 May 2022 13:01:21 -0400 Subject: [PATCH 1/9] A Single Surge Patch for Menu Accessibility - Add 'isTicked' and 'hasSubMenu' (second on mac only) - Make enter open submenus if the submens are there - Change the "Ticked" spoken label to "Checked" The logic still isnt' quite right in 6.1.6; so apply patches to make our use case work at least and revisit later with JUCE team. --- .../juce_gui_basics/menus/juce_PopupMenu.cpp | 48 +++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 1118a6e103f7..43e257ccedd9 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,7 +655,32 @@ 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)) { @@ -1258,7 +1293,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; From d6497164596fa28b9f2503300bd419fe73ebcae5 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Fri, 19 Aug 2022 14:28:57 -0400 Subject: [PATCH 2/9] Don't scale mouse position velocity by overall velocity As discussed in https://github.com/surge-synthesizer/surge/issues/6409 juce made the choice to SCALE mouse position in the vkb by overall velocity and we don't want that --- modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) { From 5835cd6e5bd3836a4265964e21af196aa270a18d Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Wed, 10 Jul 2024 10:14:17 -0400 Subject: [PATCH 3/9] risc-v and web-assembly builds (#3) * Allow building for RISC-V * Allow building for wasm Signed-off-by: falkTX Merged against 7.0.5 by baconpaul Merged against 7.0.12 by baconpaul --- modules/juce_core/juce_core.cpp | 1 + modules/juce_core/system/juce_TargetPlatform.h | 4 ++-- modules/juce_dsp/juce_dsp.cpp | 4 +++- modules/juce_dsp/juce_dsp.h | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/juce_core/juce_core.cpp b/modules/juce_core/juce_core.cpp index a61a55d0d29e..d4409b4dbbcf 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 diff --git a/modules/juce_core/system/juce_TargetPlatform.h b/modules/juce_core/system/juce_TargetPlatform.h index 9b3b495f83f5..4f221fe64709 100644 --- a/modules/juce_core/system/juce_TargetPlatform.h +++ b/modules/juce_core/system/juce_TargetPlatform.h @@ -76,6 +76,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 +91,6 @@ #else #define JUCE_MAC 1 #endif -#elif defined (__wasm__) - #define JUCE_WASM 1 #else #error "Unknown platform!" #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 From ebcf9ca05aa5cad6c2b9e904c14c0ab67b94ffed Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sun, 5 Nov 2023 13:46:50 -0500 Subject: [PATCH 4/9] Shift-F10 as well as Esc closes a menu As described in surge issue https://github.com/surge-synthesizer/surge/issues/7281 the 'esc' key in Reaper VST3 does not get delivered to the plugin menu to close the menu, so accessible users with docked reaper windows get dumped out of surge when canceling menu actions. This doesn't fix that, but it adds an alternative that Shift-F10 also closes the menu (since that is our accessible open gesture). --- modules/juce_gui_basics/menus/juce_PopupMenu.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 43e257ccedd9..e306a7ef3de1 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -686,6 +686,12 @@ struct MenuWindow final : public Component { 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; From 131a13ed648b21a394a22fa4f997f9c9c1c746f8 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Wed, 10 Jul 2024 10:16:17 -0400 Subject: [PATCH 5/9] Merge pull request from upstream JUCE repo to support builds on musl libc (#6) This commit squashes the four GLIBC/MUSL commits from https://github.com/juce-framework/JUCE/pull/1239 into our branch as a single commit (retaining a single commit to make future rebasing easier etc). Those commits were: * SystemStats: Only use locales on glibc * Linux: Add JUCE_GLIBC and JUCE_MUSL macros * SystemStats: Do not use execinfo.h on JUCE_MUSL * Native: Only use stat64 on glibc and iOS Musl 1.2.4 made the LFS64 interfaces only available when _LARGEFILE64_SOURCE is defined, and they will be removed altogether in Musl 1.2.5. --------- Co-authored-by: Violet Purcell Rebase to 7.0.12 by baconpaul --- modules/juce_core/juce_core.cpp | 2 +- modules/juce_core/native/juce_SharedCode_posix.h | 2 +- modules/juce_core/native/juce_SystemStats_linux.cpp | 12 ++++++------ modules/juce_core/system/juce_SystemStats.cpp | 2 +- modules/juce_core/system/juce_TargetPlatform.h | 9 +++++++++ 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/juce_core/juce_core.cpp b/modules/juce_core/juce_core.cpp index d4409b4dbbcf..ddff37f289c8 100644 --- a/modules/juce_core/juce_core.cpp +++ b/modules/juce_core/juce_core.cpp @@ -109,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 4f221fe64709..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. */ //============================================================================== @@ -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 //============================================================================== From f468c3a6b4a8541c9b7a653b5d0b4300ee555154 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Fri, 9 Aug 2024 08:01:37 -0400 Subject: [PATCH 6/9] Add "#" and "/" operators to Lua syntax highlighting Two simple case statement inclusions --- modules/juce_gui_extra/code_editor/juce_LuaCodeTokeniser.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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; From d539a831f7d77126fb4644056fa46e533db838a5 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Mon, 30 Sep 2024 14:15:13 -0400 Subject: [PATCH 7/9] Revert "ComponentPeer: Add isShowing() member, which more closely matches expected behaviour of Component::isShowing" This reverts commit 555b667d228439e36cbcd8f820090c1882ce3d76. --- .../juce_audio_plugin_client_Unity.cpp | 1 - modules/juce_gui_basics/components/juce_Component.cpp | 2 +- .../juce_gui_basics/native/juce_NSViewComponentPeer_mac.mm | 5 ----- .../juce_gui_basics/native/juce_UIViewComponentPeer_ios.mm | 1 - modules/juce_gui_basics/native/juce_Windowing_android.cpp | 5 ----- modules/juce_gui_basics/native/juce_Windowing_linux.cpp | 5 ----- modules/juce_gui_basics/native/juce_Windowing_windows.cpp | 5 ----- modules/juce_gui_basics/windows/juce_ComponentPeer.h | 3 --- 8 files changed, 1 insertion(+), 26 deletions(-) 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_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/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..57eefd8a1f72 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); 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; From d418c963522b25897cbcc6201b9183cf177b3987 Mon Sep 17 00:00:00 2001 From: baconpaul Date: Tue, 1 Oct 2024 19:57:01 -0400 Subject: [PATCH 8/9] Functionally revert 515e9b9 per conversation with @reuk in forum oct 1 --- modules/juce_gui_basics/native/juce_Windowing_windows.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp index 57eefd8a1f72..f1233f3d01a0 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_windows.cpp +++ b/modules/juce_gui_basics/native/juce_Windowing_windows.cpp @@ -1788,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)); From 341fe4a80fc6c158337c58f81b420c462b04f568 Mon Sep 17 00:00:00 2001 From: David Lowndes Date: Mon, 18 Nov 2024 23:53:23 +0000 Subject: [PATCH 9/9] Use reference to prevent unnecessary copy. assert opcode before it's used. Don't fail to delete memory even though it's unlikely to occur. Handle situation when SHBrowseForFolder is cancelled (returns null). Several places appear to be checking the wrong thing after calling SafeArrayCreateVector. --- .../javascript/choc/containers/choc_Value.h | 2 +- .../choc/javascript/choc_javascript_QuickJS.h | 2 +- .../fonts/harfbuzz/hb-directwrite.cc | 7 ++-- .../accessibility/juce_UIAHelpers_windows.h | 2 +- .../juce_UIATextProvider_windows.h | 32 +++++++++++-------- .../native/juce_FileChooser_windows.cpp | 29 +++++++++-------- 6 files changed, 43 insertions(+), 31 deletions(-) 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_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/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