reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 243671d74c07be95202fefe79ffddc1d3f35d39a
parent 8c6c1eb915484d7d746bc6b1896145a594edf41f
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Thu, 28 Nov 2019 14:31:32 -0500

use REAPER-provided SWELL on macOS

This replaces the use of SWELL's private and unexported ListView_GetScroll
function with REAPER's undocumented ListView_HeaderHitTest API function (5.1+).

An alternative solution would have been to extract SWELL's ListView_GetScroll.

More informations at <https://forum.cockos.com/showthread.php?t=227910>.

ListView update optimization and richtext disabling patches are expected
to land in upstream WDL after REAPER 6.03 is released.

Diffstat:
M.travis.yml | 7+------
MREADME.md | 7+------
Mcmake/FindSWELL.cmake | 38+++++++-------------------------------
Msrc/listview.cpp | 19++++++++-----------
Msrc/main.cpp | 5+++++
Avendor/reaper_plugin_secrets.h | 6++++++
6 files changed, 28 insertions(+), 54 deletions(-)

diff --git a/.travis.yml b/.travis.yml @@ -9,14 +9,9 @@ install: - wget -nv https://github.com/reaper-oss/sws/raw/master/reaper/reaper_plugin.h -P vendor - wget -nv https://gist.github.com/cfillion/da355e8278048de08ae065d6fe6031c1/raw/reaper_plugin_functions.h -P vendor - git clone -q --depth 1 https://github.com/justinfrankel/WDL.git vendor/WDL - - # SWELL: optimize ListView_SetItemText on macOS - - curl -fsSL https://github.com/cfillion/WDL/commit/e2ec43b91a02cbea0494105e68eba57ffe27ca42.patch | git -C vendor/WDL am - # SWELL: disable rich text in multiline textboxes on macOS - - curl -fsSL https://github.com/cfillion/WDL/commit/c27fca07aa59525f45d9a2d7766ba51d6f5a34fc.patch | git -C vendor/WDL am script: - cmake -B build - -DCMAKE_BUILD_TYPE=RelWithDebInfo + -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="$ARCH" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 -DCMAKE_TOOLCHAIN_FILE=cmake/brew-llvm.cmake diff --git a/README.md b/README.md @@ -43,11 +43,6 @@ them separately): Install Boost and Catch2 using [Homebrew](https://brew.sh) (recommended). The build tools can be installed using `xcode-select --install` or the Xcode IDE. -Apply these patches to WDL: - -- [optimize-listview-setitemtext](https://github.com/cfillion/WDL/commit/e2ec43b91a02cbea0494105e68eba57ffe27ca42.patch) -- [richtext-off](https://github.com/cfillion/WDL/commit/c27fca07aa59525f45d9a2d7766ba51d6f5a34fc.patch) - #### Windows MSVC can be installed with the [Build Tools for Visual Studio]( @@ -138,7 +133,7 @@ macOS 10.14 or older, Xcode 9 and the latest Clang (`brew install llvm`) are required for producing 32-bit builds. cmake -B build \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_OSX_ARCHITECTURES=i386 \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \ -DCMAKE_TOOLCHAIN_FILE=cmake/brew-llvm.cmake diff --git a/cmake/FindSWELL.cmake b/cmake/FindSWELL.cmake @@ -15,41 +15,17 @@ set(SWELL_DIR "${SWELL_INCLUDE_DIR}/swell") set(SWELL_RESGEN "${SWELL_DIR}/mac_resgen.php") include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(SWELL REQUIRED_VARS SWELL_DIR SWELL_INCLUDE_DIR) +find_package_handle_standard_args(SWELL REQUIRED_VARS SWELL_DIR) + +add_library(swell ${SWELL_DIR}/swell-modstub$<IF:$<BOOL:${APPLE}>,.mm,-generic.cpp>) if(APPLE) - add_library(swell - ${SWELL_DIR}/swell.cpp - ${SWELL_DIR}/swell-ini.cpp - ${SWELL_DIR}/swell-miscdlg.mm - ${SWELL_DIR}/swell-gdi.mm - ${SWELL_DIR}/swell-kb.mm - ${SWELL_DIR}/swell-menu.mm - ${SWELL_DIR}/swell-misc.mm - ${SWELL_DIR}/swell-dlg.mm - ${SWELL_DIR}/swell-wnd.mm - ) - - target_compile_definitions(swell PRIVATE SWELL_APP_PREFIX=SWELL_REAPACK) - set_target_properties(swell PROPERTIES CXX_STANDARD 98) - - find_library(COCOA Cocoa) - find_library(CARBON Carbon) - find_library(METAL Metal) - mark_as_advanced(COCOA CARBON METAL) - target_link_libraries(swell PUBLIC ${COCOA} ${CARBON}) - - if(METAL) - target_link_libraries(swell PUBLIC ${METAL}) - else() - target_compile_definitions(swell PRIVATE SWELL_NO_METAL) - endif() -else() - add_library(swell ${SWELL_DIR}/swell-modstub-generic.cpp) - - target_compile_definitions(swell PUBLIC SWELL_PROVIDED_BY_APP) + find_library(APPKIT AppKit) + mark_as_advanced(APPKIT) + target_link_libraries(swell PUBLIC ${APPKIT}) endif() +target_compile_definitions(swell PUBLIC SWELL_PROVIDED_BY_APP) target_include_directories(swell INTERFACE ${SWELL_INCLUDE_DIR}) add_library(SWELL::swell ALIAS swell) diff --git a/src/listview.cpp b/src/listview.cpp @@ -25,8 +25,7 @@ #include <boost/algorithm/string/case_conv.hpp> #include <cassert> - -bool ListView_GetScroll(HWND, POINT *); // undocumented macOS SWELL function +#include <reaper_plugin_secrets.h> static int adjustWidth(const int points) { @@ -384,22 +383,20 @@ bool ListView::headerHitTest(const int x, const int y) const GetWindowRect(ListView_GetHeader(handle()), &rect); const int headerHeight = rect.bottom - rect.top; -#elif __APPLE__ - // On macOS the ListView's zero client y coordinate is the first item's - // position including its scroll offset. - // ListView_GetScroll is not available in REAPER-provided SWELL - POINT scroll; - ListView_GetScroll(handle(), &scroll); - - const int headerHeight = scroll.y; -#else +#elif !defined(__APPLE__) const int headerHeight = SWELL_GetListViewHeaderHeight(handle()); #endif POINT point{x, y}; ScreenToClient(handle(), &point); +#ifdef __APPLE__ + // This was broken on Linux and used a hard-coded header height on Windows + // Fixed in REAPER v6.03 + return ListView_HeaderHitTest(handle(), point); +#else return point.y <= headerHeight; +#endif } int ListView::itemUnder(const int x, const int y, bool *overIcon) const diff --git a/src/main.cpp b/src/main.cpp @@ -24,6 +24,7 @@ #define REAPERAPI_IMPLEMENT #include <reaper_plugin_functions.h> +#include <reaper_plugin_secrets.h> #define REQUIRED_API(name) {reinterpret_cast<void **>(&name), #name, true} #define OPTIONAL_API(name) {reinterpret_cast<void **>(&name), #name, false} @@ -43,6 +44,10 @@ static bool loadAPI(void *(*getFunc)(const char *)) REQUIRED_API(ShowMessageBox), OPTIONAL_API(AddRemoveReaScript), // v5.12 + +#ifdef __APPLE__ + REQUIRED_API(ListView_HeaderHitTest), // v5.1, undocumented +#endif }; for(const ApiFunc &func : funcs) { diff --git a/vendor/reaper_plugin_secrets.h b/vendor/reaper_plugin_secrets.h @@ -0,0 +1,6 @@ +#include "reaper_plugin_functions.h" + +// The following API functions are undocumented and not included in +// reaper_plugin_functions.h. + +REAPERAPI_DEF bool (*ListView_HeaderHitTest)(HWND, POINT);