mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 21:08:12 +08:00
* 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>
53 lines
1.1 KiB
Rust
53 lines
1.1 KiB
Rust
use cef::rc::{Rc, RcImpl};
|
|
use cef::sys::{_cef_client_t, cef_base_ref_counted_t};
|
|
use cef::{ImplClient, RenderHandler, WrapClient};
|
|
|
|
pub(crate) struct ClientImpl {
|
|
object: *mut RcImpl<_cef_client_t, Self>,
|
|
render_handler: RenderHandler,
|
|
}
|
|
impl ClientImpl {
|
|
pub(crate) fn new(render_handler: RenderHandler) -> Self {
|
|
Self {
|
|
object: std::ptr::null_mut(),
|
|
render_handler,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ImplClient for ClientImpl {
|
|
fn render_handler(&self) -> Option<RenderHandler> {
|
|
Some(self.render_handler.clone())
|
|
}
|
|
|
|
fn get_raw(&self) -> *mut _cef_client_t {
|
|
self.object.cast()
|
|
}
|
|
}
|
|
|
|
impl Clone for ClientImpl {
|
|
fn clone(&self) -> Self {
|
|
unsafe {
|
|
let rc_impl = &mut *self.object;
|
|
rc_impl.interface.add_ref();
|
|
}
|
|
Self {
|
|
object: self.object,
|
|
render_handler: self.render_handler.clone(),
|
|
}
|
|
}
|
|
}
|
|
impl Rc for ClientImpl {
|
|
fn as_base(&self) -> &cef_base_ref_counted_t {
|
|
unsafe {
|
|
let base = &*self.object;
|
|
std::mem::transmute(&base.cef_object)
|
|
}
|
|
}
|
|
}
|
|
impl WrapClient for ClientImpl {
|
|
fn wrap_rc(&mut self, object: *mut RcImpl<_cef_client_t, Self>) {
|
|
self.object = object;
|
|
}
|
|
}
|