Enable AppleMomentumScrollSupported on macOS

This commit is contained in:
Benau 2023-11-12 12:56:28 +08:00
parent bd245e17bf
commit 8cd6a231cc
3 changed files with 21 additions and 0 deletions

View File

@ -550,6 +550,16 @@ if(IOS)
set_source_files_properties(source/Irrlicht/CIrrDeviceiOS.mm PROPERTIES LANGUAGE C)
endif()
if (NOT SERVER_ONLY AND APPLE AND NOT IOS)
set(IRRLICHT_SOURCES
${IRRLICHT_SOURCES}
source/Irrlicht/MacOS.mm)
set_source_files_properties(source/Irrlicht/MacOS.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti")
set_source_files_properties(source/Irrlicht/MacOS.mm PROPERTIES LANGUAGE C)
endif()
add_library(stkirrlicht STATIC ${IRRLICHT_SOURCES})
target_link_libraries(stkirrlicht ${ZLIB_LIBRARY})

View File

@ -52,6 +52,7 @@ namespace irr
} // end namespace irr
extern "C" void init_objc(SDL_SysWMinfo* info, float* top, float* bottom, float* left, float* right);
extern "C" void enable_momentum_scroll();
extern "C" int handle_app_event(void* userdata, SDL_Event* event);
extern "C" void Android_initDisplayCutout(float* top, float* bottom, float* left, float* right, int* initial_orientation);
extern "C" int Android_disablePadding();
@ -122,6 +123,10 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
// create window
if (CreationParams.DriverType != video::EDT_NULL)
{
#if defined(_IRR_OSX_PLATFORM_) && !defined(IOS_STK)
enable_momentum_scroll();
#endif
// create the window, only if we do not use the null device
if (!Close && createWindow())
{

View File

@ -0,0 +1,6 @@
#import <AppKit/AppKit.h>
extern "C" void enable_momentum_scroll()
{
[[NSUserDefaults standardUserDefaults] setBool: YES forKey: @"AppleMomentumScrollSupported"];
}