Add macOS Cocoa port and CEF helper support
Introduce a macOS Cocoa-based UI and CEF helper subprocess support. CMake: enable OBJCXX on Apple, treat mac sources as .mm, set -fobjc-arc, link Cocoa frameworks, and generate helper app targets using a mac Info.plist template; keep libcef logical target off macOS. Implementation: add Objective-C++ implementations for browser_host and nebula_window, convert startup to ObjC++ (prepare NSApplication), add process_helper_mac (CEF helper entry) and load CEF library from main/main_bigpicture on mac. Tooling/docs: add .clangd fallback flags, compile_commands symlink helper, update cross-platform docs for mac status. Misc: add menu-popup UI page, define UNREFERENCED_PARAMETER in platform/types.h, small code cleanups (use (void)layout, include platform/types.h) and update .gitignore.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#include "platform/startup.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <sys/file.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "include/cef_command_line.h"
|
||||
#include "ui/paths.h"
|
||||
|
||||
namespace nebula::platform {
|
||||
namespace {
|
||||
|
||||
int g_single_instance_lock = -1;
|
||||
|
||||
} // namespace
|
||||
|
||||
void PrepareApp() {
|
||||
@autoreleasepool {
|
||||
[NSApplication sharedApplication];
|
||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||
[NSApp finishLaunching];
|
||||
}
|
||||
}
|
||||
|
||||
bool TryAcquireSingleInstance() {
|
||||
const auto lock_path = nebula::ui::GetUserDataDirectory() / ".nebula_instance.lock";
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(lock_path.parent_path(), ec);
|
||||
|
||||
g_single_instance_lock = open(lock_path.c_str(), O_CREAT | O_RDWR, 0644);
|
||||
if (g_single_instance_lock < 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return flock(g_single_instance_lock, LOCK_EX | LOCK_NB) == 0;
|
||||
}
|
||||
|
||||
CefMainArgs MakeMainArgs(const AppStartup& startup) {
|
||||
return CefMainArgs(startup.argc, startup.argv);
|
||||
}
|
||||
|
||||
void InitCommandLine(CefRefPtr<CefCommandLine> command_line, const AppStartup& startup) {
|
||||
command_line->InitFromArgv(startup.argc, startup.argv);
|
||||
}
|
||||
|
||||
void ConfigureCefSettings(CefSettings& settings) {
|
||||
const std::string user_data_dir = nebula::ui::GetUserDataDirectory().string();
|
||||
const std::string cache_dir = nebula::ui::GetCacheDirectory().string();
|
||||
if (!user_data_dir.empty()) {
|
||||
CefString(&settings.root_cache_path).FromString(user_data_dir);
|
||||
}
|
||||
if (!cache_dir.empty()) {
|
||||
CefString(&settings.cache_path).FromString(cache_dir);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace nebula::platform
|
||||
Reference in New Issue
Block a user