mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 14:58:12 +08:00
Desktop: Switch to the latest unreleased version of Winit (#3177)
* Use unstable winit * Improve * Remove unnecessary heap indirection
This commit is contained in:
+19
-29
@@ -1,35 +1,22 @@
|
||||
use std::process::exit;
|
||||
use std::time::Instant;
|
||||
|
||||
use cef::CefHandler;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use winit::event_loop::EventLoop;
|
||||
|
||||
use graphite_desktop_wrapper::WgpuContext;
|
||||
|
||||
pub(crate) mod consts;
|
||||
|
||||
mod app;
|
||||
mod cef;
|
||||
|
||||
mod dirs;
|
||||
mod event;
|
||||
mod native_window;
|
||||
|
||||
mod persist;
|
||||
mod render;
|
||||
|
||||
mod app;
|
||||
use app::WinitApp;
|
||||
|
||||
mod dirs;
|
||||
mod persist;
|
||||
|
||||
use graphite_desktop_wrapper::messages::DesktopWrapperMessage;
|
||||
use graphite_desktop_wrapper::{NodeGraphExecutionResult, WgpuContext};
|
||||
|
||||
pub(crate) enum CustomEvent {
|
||||
UiUpdate(wgpu::Texture),
|
||||
ScheduleBrowserWork(Instant),
|
||||
WebCommunicationInitialized,
|
||||
DesktopWrapperMessage(DesktopWrapperMessage),
|
||||
NodeGraphExecutionResult(NodeGraphExecutionResult),
|
||||
CloseWindow,
|
||||
}
|
||||
use app::App;
|
||||
use cef::CefHandler;
|
||||
use event::CreateAppEventSchedulerEventLoopExt;
|
||||
|
||||
fn main() {
|
||||
tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
|
||||
@@ -46,13 +33,18 @@ fn main() {
|
||||
|
||||
let wgpu_context = futures::executor::block_on(WgpuContext::new()).unwrap();
|
||||
|
||||
let event_loop = EventLoop::<CustomEvent>::with_user_event().build().unwrap();
|
||||
let event_loop = EventLoop::new().unwrap();
|
||||
let (app_event_sender, app_event_receiver) = std::sync::mpsc::channel();
|
||||
let app_event_scheduler = event_loop.create_app_event_scheduler(app_event_sender);
|
||||
|
||||
let (window_size_sender, window_size_receiver) = std::sync::mpsc::channel();
|
||||
|
||||
let cef_handler = cef::CefHandler::new(window_size_receiver, event_loop.create_proxy(), wgpu_context.clone());
|
||||
let cef_handler = cef::CefHandler::new(wgpu_context.clone(), app_event_scheduler.clone(), window_size_receiver);
|
||||
let cef_context = match cef_context_builder.initialize(cef_handler) {
|
||||
Ok(c) => c,
|
||||
Ok(c) => {
|
||||
tracing::info!("CEF initialized successfully");
|
||||
c
|
||||
}
|
||||
Err(cef::InitError::AlreadyRunning) => {
|
||||
tracing::error!("Another instance is already running, Exiting.");
|
||||
exit(0);
|
||||
@@ -71,9 +63,7 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
tracing::info!("CEF initialized successfully");
|
||||
let mut app = App::new(Box::new(cef_context), window_size_sender, wgpu_context, app_event_receiver, app_event_scheduler);
|
||||
|
||||
let mut winit_app = WinitApp::new(Box::new(cef_context), window_size_sender, wgpu_context, event_loop.create_proxy());
|
||||
|
||||
event_loop.run_app(&mut winit_app).unwrap();
|
||||
event_loop.run_app(&mut app).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user