mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 23:40:02 +01:00
OSX support for 'OpenFile' system message (aka open vimix when selecting
session file in finder).
This commit is contained in:
@@ -13,10 +13,10 @@ if(UNIX)
|
|||||||
|
|
||||||
# the RPATH to be used when installing
|
# the RPATH to be used when installing
|
||||||
set(CMAKE_SKIP_RPATH TRUE)
|
set(CMAKE_SKIP_RPATH TRUE)
|
||||||
|
|
||||||
set(OpenGL_DIR /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/)
|
set(OpenGL_DIR /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/)
|
||||||
set(CMAKE_OSX_ARCHITECTURES x86_64)
|
set(CMAKE_OSX_ARCHITECTURES x86_64)
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
|
||||||
|
# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X version to target for deployment")
|
||||||
|
|
||||||
else()
|
else()
|
||||||
add_definitions(-DLINUX)
|
add_definitions(-DLINUX)
|
||||||
@@ -283,6 +283,7 @@ set(VMIX_SRCS
|
|||||||
ActionManager.cpp
|
ActionManager.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
set(VMIX_RSC_FILES
|
set(VMIX_RSC_FILES
|
||||||
./rsc/shaders/simple.fs
|
./rsc/shaders/simple.fs
|
||||||
./rsc/shaders/simple.vs
|
./rsc/shaders/simple.vs
|
||||||
@@ -370,6 +371,7 @@ IF(APPLE)
|
|||||||
# create the application
|
# create the application
|
||||||
add_executable(${VMIX_BINARY} MACOSX_BUNDLE
|
add_executable(${VMIX_BINARY} MACOSX_BUNDLE
|
||||||
${VMIX_SRCS}
|
${VMIX_SRCS}
|
||||||
|
./osx/CustomDelegate.m
|
||||||
${IMGUITEXTEDIT_SRC}
|
${IMGUITEXTEDIT_SRC}
|
||||||
${MACOSX_BUNDLE_ICON_FILE}
|
${MACOSX_BUNDLE_ICON_FILE}
|
||||||
)
|
)
|
||||||
@@ -378,6 +380,11 @@ IF(APPLE)
|
|||||||
set(MACOSX_BUNDLE_PLIST_FILE ${CMAKE_SOURCE_DIR}/osx/Info.plist)
|
set(MACOSX_BUNDLE_PLIST_FILE ${CMAKE_SOURCE_DIR}/osx/Info.plist)
|
||||||
set_target_properties(${VMIX_BINARY} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${MACOSX_BUNDLE_PLIST_FILE})
|
set_target_properties(${VMIX_BINARY} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${MACOSX_BUNDLE_PLIST_FILE})
|
||||||
|
|
||||||
|
set(PLATFORM_LIBS
|
||||||
|
"-framework CoreFoundation"
|
||||||
|
"-framework Appkit"
|
||||||
|
)
|
||||||
|
|
||||||
ELSE(APPLE)
|
ELSE(APPLE)
|
||||||
|
|
||||||
add_executable(${VMIX_BINARY}
|
add_executable(${VMIX_BINARY}
|
||||||
@@ -385,6 +392,9 @@ ELSE(APPLE)
|
|||||||
${IMGUITEXTEDIT_SRC}
|
${IMGUITEXTEDIT_SRC}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(PLATFORM_LIBS ""
|
||||||
|
)
|
||||||
|
|
||||||
ENDIF(APPLE)
|
ENDIF(APPLE)
|
||||||
|
|
||||||
|
|
||||||
@@ -421,6 +431,7 @@ target_link_libraries(${VMIX_BINARY} LINK_PRIVATE
|
|||||||
IMGUI
|
IMGUI
|
||||||
OSCPACK
|
OSCPACK
|
||||||
vmix::rc
|
vmix::rc
|
||||||
|
${PLATFORM_LIBS}
|
||||||
)
|
)
|
||||||
|
|
||||||
macro_display_feature_log()
|
macro_display_feature_log()
|
||||||
@@ -434,7 +445,7 @@ SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
|
|||||||
SET(CPACK_PACKAGE_CONTACT "bruno.herbelin@gmail.com")
|
SET(CPACK_PACKAGE_CONTACT "bruno.herbelin@gmail.com")
|
||||||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt")
|
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt")
|
||||||
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
|
SET(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||||
SET(CPACK_PACKAGE_VERSION_MINOR "3")
|
SET(CPACK_PACKAGE_VERSION_MINOR "4")
|
||||||
SET(CPACK_PACKAGE_VENDOR "Bruno Herbelin")
|
SET(CPACK_PACKAGE_VENDOR "Bruno Herbelin")
|
||||||
SET(CPACK_SOURCE_IGNORE_FILES
|
SET(CPACK_SOURCE_IGNORE_FILES
|
||||||
"/\\\\.git/"
|
"/\\\\.git/"
|
||||||
@@ -471,7 +482,7 @@ IF(APPLE)
|
|||||||
### TODO configure auto to find installation dir of gst
|
### TODO configure auto to find installation dir of gst
|
||||||
|
|
||||||
# intall the gst-plugin-scanner program (used by plugins at load time)
|
# intall the gst-plugin-scanner program (used by plugins at load time)
|
||||||
install(FILES "/usr/local/Cellar/gstreamer/1.18.0/libexec/gstreamer-1.0/gst-plugin-scanner"
|
install(FILES "/usr/local/Cellar/gstreamer/1.18.1/libexec/gstreamer-1.0/gst-plugin-scanner"
|
||||||
DESTINATION "${plugin_dest_dir}"
|
DESTINATION "${plugin_dest_dir}"
|
||||||
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
COMPONENT Runtime
|
COMPONENT Runtime
|
||||||
@@ -482,11 +493,11 @@ IF(APPLE)
|
|||||||
|
|
||||||
# Install the gst-plugins (all those installed with brew )
|
# Install the gst-plugins (all those installed with brew )
|
||||||
install(DIRECTORY "${PKG_GSTREAMER_PLUGIN_DIR}" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
install(DIRECTORY "${PKG_GSTREAMER_PLUGIN_DIR}" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||||
install(DIRECTORY "/usr/local/Cellar/gst-plugins-base/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
install(DIRECTORY "/usr/local/Cellar/gst-plugins-base/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||||
install(DIRECTORY "/usr/local/Cellar/gst-plugins-good/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
install(DIRECTORY "/usr/local/Cellar/gst-plugins-good/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||||
# install(DIRECTORY "/usr/local/Cellar/gst-plugins-bad/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
# install(DIRECTORY "/usr/local/Cellar/gst-plugins-bad/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||||
install(DIRECTORY "/usr/local/Cellar/gst-plugins-ugly/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
install(DIRECTORY "/usr/local/Cellar/gst-plugins-ugly/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||||
install(DIRECTORY "/usr/local/Cellar/gst-libav/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
install(DIRECTORY "/usr/local/Cellar/gst-libav/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime)
|
||||||
|
|
||||||
# install locally recompiled gst-plugins-bad
|
# install locally recompiled gst-plugins-bad
|
||||||
install(FILES "/Users/herbelin/Development/gst/gst-plugins-bad-1.18.0/build/ext/libde265/libgstde265.dylib" DESTINATION "${plugin_dest_dir}/gstreamer-1.0" COMPONENT Runtime)
|
install(FILES "/Users/herbelin/Development/gst/gst-plugins-bad-1.18.0/build/ext/libde265/libgstde265.dylib" DESTINATION "${plugin_dest_dir}/gstreamer-1.0" COMPONENT Runtime)
|
||||||
|
|||||||
11
main.cpp
11
main.cpp
@@ -31,13 +31,20 @@
|
|||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(APPLE)
|
||||||
|
extern "C"{
|
||||||
|
void forward_load_message(const char * filename){
|
||||||
|
Settings::application.argument_file = std::string(filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void drawScene()
|
void drawScene()
|
||||||
{
|
{
|
||||||
Mixer::manager().draw();
|
Mixer::manager().draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// one extra argument is given
|
// one extra argument is given
|
||||||
|
|||||||
@@ -11,4 +11,4 @@ void * get_current_nsopengl_context();
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COCOA_TOOLKIT_H
|
#endif // COCOA_TOOLKIT_H
|
||||||
|
|||||||
10
osx/CustomDelegate.h
Normal file
10
osx/CustomDelegate.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface GLFWCustomDelegate : NSObject
|
||||||
|
+ (void)load; // load is called before even main() is run (as part of objc class registration)
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
49
osx/CustomDelegate.m
Normal file
49
osx/CustomDelegate.m
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#import "CustomDelegate.h"
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
|
||||||
|
// part of your application
|
||||||
|
extern void forward_load_message(const char * filename);
|
||||||
|
|
||||||
|
@implementation GLFWCustomDelegate
|
||||||
|
|
||||||
|
+ (void)load{
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
Class class = objc_getClass("GLFWApplicationDelegate");
|
||||||
|
|
||||||
|
[GLFWCustomDelegate swizzle:class src:@selector(application:openFile:) tgt:@selector(swz_application:openFile:)];
|
||||||
|
[GLFWCustomDelegate swizzle:class src:@selector(application:openFiles:) tgt:@selector(swz_application:openFiles:)];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void) swizzle:(Class) original_c src:(SEL)original_s tgt:(SEL)target_s{
|
||||||
|
Class target_c = [GLFWCustomDelegate class];
|
||||||
|
Method originalMethod = class_getInstanceMethod(original_c, original_s);
|
||||||
|
Method swizzledMethod = class_getInstanceMethod(target_c, target_s);
|
||||||
|
|
||||||
|
BOOL didAddMethod =
|
||||||
|
class_addMethod(original_c,
|
||||||
|
original_s,
|
||||||
|
method_getImplementation(swizzledMethod),
|
||||||
|
method_getTypeEncoding(swizzledMethod));
|
||||||
|
|
||||||
|
if (didAddMethod) {
|
||||||
|
class_replaceMethod(original_c,
|
||||||
|
target_s,
|
||||||
|
method_getImplementation(originalMethod),
|
||||||
|
method_getTypeEncoding(originalMethod));
|
||||||
|
} else {
|
||||||
|
method_exchangeImplementations(originalMethod, swizzledMethod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)swz_application:(NSApplication *)sender openFile:(NSString *)filename{
|
||||||
|
forward_load_message(filename.UTF8String);
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)swz_application:(NSApplication *)sender openFiles:(NSArray<NSString *> *)filenames{
|
||||||
|
forward_load_message(filenames.firstObject.UTF8String);
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
@@ -9,22 +9,18 @@
|
|||||||
<key>CFBundleDocumentTypes</key>
|
<key>CFBundleDocumentTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
|
||||||
<array>
|
|
||||||
<string>mix</string>
|
|
||||||
</array>
|
|
||||||
<key>CFBundleTypeIconFile</key>
|
|
||||||
<string>vimix.icns</string>
|
|
||||||
<key>CFBundleTypeName</key>
|
<key>CFBundleTypeName</key>
|
||||||
<string>GLMixer Session</string>
|
<string>vimix session</string>
|
||||||
<key>CFBundleTypeOSTypes</key>
|
|
||||||
<array>
|
|
||||||
<string>MIX </string>
|
|
||||||
</array>
|
|
||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Editor</string>
|
<string>Editor</string>
|
||||||
<key>LSIsAppleDefaultForType</key>
|
<key>LSIsAppleDefaultForType</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>LSHandlerRank</key>
|
||||||
|
<string>Owner</string>
|
||||||
|
<key>LSItemContentTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>com.bhbn.mix</string>
|
||||||
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
|
|||||||
Reference in New Issue
Block a user