mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Discover the magic of +whole-archive to avoid relying on hacks to load the objective-C++ code in webview native
This commit is contained in:
@@ -10,6 +10,8 @@ fn main() {
|
||||
.cpp(true)
|
||||
.flag("--std=c++17")
|
||||
.file("src/mac_application.mm")
|
||||
.link_lib_modifier("+whole-archive")
|
||||
.warnings(false)
|
||||
.compile("mac_application");
|
||||
|
||||
println!("cargo::rerun-if-changed=src/mac_application.mm");
|
||||
|
||||
@@ -1,10 +1 @@
|
||||
#[cfg(target_os = "macos")]
|
||||
unsafe extern "C" {
|
||||
fn get_swizzled_idiot();
|
||||
}
|
||||
|
||||
// Not actually called but I need a chain of reference so that the objc code is compiled in.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn rt_native_webview_init() {
|
||||
unsafe { get_swizzled_idiot() };
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <objc/runtime.h>
|
||||
|
||||
#include <cstdio>
|
||||
// #include <cstdio>
|
||||
|
||||
#include "include/cef_application_mac.h"
|
||||
|
||||
@@ -32,21 +32,14 @@ bool g_handling_send_event = false;
|
||||
}
|
||||
|
||||
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
|
||||
printf("setHandlingSendEvent: %i\n", (int) handlingSendEvent);
|
||||
// printf("setHandlingSendEvent: %i\n", (int) handlingSendEvent);
|
||||
g_handling_send_event = handlingSendEvent;
|
||||
}
|
||||
|
||||
- (void)_swizzled_sendEvent:(NSEvent*)event {
|
||||
printf("send it");
|
||||
// printf("send it\n");
|
||||
CefScopedSendingEvent sendingEventScoper;
|
||||
[self _swizzled_sendEvent:event];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
extern "C" {
|
||||
void get_swizzled_idiot() {
|
||||
NSApplication* app = [NSApplication sharedApplication];
|
||||
[app isHandlingSendEvent];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user