Files
Graphite/desktop/src/cef/internal/non_browser_app.rs
Timon 30abc92900 Implement basic desktop app with chromium embeded framework (#2874)
* Remove tauri based desktop app

* Allow bzip-1.0.6 license

* Implement basic cef based desktop app

* Cleanup build setup

* Use wait until and execute cef loop more frequently

* Remove custom do browser work event

* Move WinitApp into its own module

* Cleanup event handling

* Cleanup + Scheudule cef message loop work

* Fix cpu overheating on idle: https://xkcd.com/1172/

* Use tracing crate for logging instead of println

* Rebase to main

---------

Co-authored-by: Dennis Kobert <dennis@kobert.dev>
2025-07-23 20:27:55 +02:00

48 lines
1.1 KiB
Rust

use cef::rc::{Rc, RcImpl};
use cef::sys::{_cef_app_t, cef_base_ref_counted_t};
use cef::{App, ImplApp, SchemeRegistrar, WrapApp};
use crate::cef::scheme_handler::GraphiteSchemeHandlerFactory;
pub(crate) struct NonBrowserAppImpl {
object: *mut RcImpl<_cef_app_t, Self>,
}
impl NonBrowserAppImpl {
pub(crate) fn app() -> App {
App::new(Self { object: std::ptr::null_mut() })
}
}
impl ImplApp for NonBrowserAppImpl {
fn on_register_custom_schemes(&self, registrar: Option<&mut SchemeRegistrar>) {
GraphiteSchemeHandlerFactory::register_schemes(registrar);
}
fn get_raw(&self) -> *mut _cef_app_t {
self.object.cast()
}
}
impl Clone for NonBrowserAppImpl {
fn clone(&self) -> Self {
unsafe {
let rc_impl = &mut *self.object;
rc_impl.interface.add_ref();
}
Self { object: self.object }
}
}
impl Rc for NonBrowserAppImpl {
fn as_base(&self) -> &cef_base_ref_counted_t {
unsafe {
let base = &*self.object;
std::mem::transmute(&base.cef_object)
}
}
}
impl WrapApp for NonBrowserAppImpl {
fn wrap_rc(&mut self, object: *mut RcImpl<_cef_app_t, Self>) {
self.object = object;
}
}