Skip to content

Conversation

tasuren
Copy link
Contributor

@tasuren tasuren commented Oct 17, 2025

It is related #96.
It partially ports SimpleApplication from original cefsimple, and resolves right-click crush on macOS.


By the way, I realized my first commit message, feat: port SimpleApplication from original cefsimple, might be slightly misleading. This is a partial port to fix the right-click issue, not a full port of SimpleApplication. It contains missing features such as -terminate: method and SimpleAppDelegate.

Would you prefer if I rebased to update the commit message to be more precise (e.g., partially port...)? Or are you happy to merge it as is, perhaps squashing and editing the message on your end?

I'm happy to do whatever is easiest for you. Thanks.

Adds Rust bindings for the Objective-C protocols required for proper
application handling on macOS (CrAppProtocol, CrAppControlProtocol,
and CefAppProtocol) using the objc2 crate.

These bindings are necessary to correctly implement an NSApplication
subclass, which is a foundational step for porting the official
cefsimple application logic and fixing related crashes.

Refs: tauri-apps#96
Adds SimpleApplication implementing CefAppProtocol.

Refs: tauri-apps#96
Updates the cefsimple example on macOS to use the new
`cef::application_mac::SimpleApplication`.

This properly initializes the application instance, resolving the crash
that previously occurred during right-click events.

Refs: tauri-apps#96
@@ -0,0 +1,121 @@
use std::cell::Cell;
Copy link
Contributor

@csmoe csmoe Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This SimpleApplication should be move to examples?
As for projects integrate cef, they usually have their own NSApplication definition, We should leave it in examples code for reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @csmoe, thanks for taking the time to review my PR.

That is a fair point. My initial decision to place SimpleApplication in the cef crate was based on an earlier discussion with @wravery on the issue.

He suggested the following, which led me to believe it would be a useful utility within the cef crate itself:

I agree, it would be good to include these in the crate itself, although I recommend putting them in the cef crate rather than the underlying cef-dll-sys crate. There are already precedents there for Mac-only modules like cef::library_loader and cef::sandbox which do similar things.

I think even having a concrete implementation of SimpleApplication with safe defaults makes sense...

#96 (comment)

Your point that most users integrating cef will likely have their own NSApplication also makes a lot of sense. It's possible I mistakenly assumed his suggestion to "include these in the cef crate itself" also applied to the concrete SimpleApplication implementation, and not just the protocol bindings.

What are your thoughts on this, @wravery?

I'm happy to move the SimpleApplication code to examples if that's the preferred approach. I just want to make sure I'm following the best direction for the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants