gagaddji3.0
This commit is contained in:
parent
5cf8e23b47
commit
f2e4a9b806
|
|
@ -16,13 +16,15 @@ const DEFAULT_LOGICAL_SIZE: (u32, u32) = (480, 640);
|
||||||
const MIN_LOGICAL_SIZE: (u32, u32) = (380, 220);
|
const MIN_LOGICAL_SIZE: (u32, u32) = (380, 220);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
init_logging();
|
|
||||||
let plugin_root = discover_plugin_root();
|
let plugin_root = discover_plugin_root();
|
||||||
if let Some(root) = plugin_root.as_deref() {
|
if let Err(e) = layers::ffi::init_native_shell(plugin_root.as_deref()) {
|
||||||
layers::ui::colors::init(Some(root));
|
eprintln!("layers: init_native_shell failed: {e}");
|
||||||
} else {
|
std::process::exit(2);
|
||||||
layers::ui::colors::init(None);
|
|
||||||
}
|
}
|
||||||
|
tracing::info!(
|
||||||
|
plugin_root = ?plugin_root,
|
||||||
|
"layers shell: starting native event loop",
|
||||||
|
);
|
||||||
|
|
||||||
if let Err(e) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(run)) {
|
if let Err(e) = std::panic::catch_unwind(std::panic::AssertUnwindSafe(run)) {
|
||||||
tracing::error!("layers shell panicked: {e:?}");
|
tracing::error!("layers shell panicked: {e:?}");
|
||||||
|
|
@ -55,6 +57,7 @@ impl ApplicationHandler for ShellApp {
|
||||||
if self.window.is_some() {
|
if self.window.is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
tracing::info!("resumed: creating window");
|
||||||
let colors = layers::ui::colors::get();
|
let colors = layers::ui::colors::get();
|
||||||
let attrs = WindowAttributes::default()
|
let attrs = WindowAttributes::default()
|
||||||
.with_title("Layers")
|
.with_title("Layers")
|
||||||
|
|
@ -83,14 +86,27 @@ impl ApplicationHandler for ShellApp {
|
||||||
.expect("winit: display handle")
|
.expect("winit: display handle")
|
||||||
.as_raw();
|
.as_raw();
|
||||||
|
|
||||||
let handle = ViewportHandle::new_from_raw(
|
tracing::info!(
|
||||||
|
"creating viewport handle: {}x{} @ {}",
|
||||||
|
inner.width,
|
||||||
|
inner.height,
|
||||||
|
scale
|
||||||
|
);
|
||||||
|
let handle = match ViewportHandle::new_from_raw(
|
||||||
raw_window,
|
raw_window,
|
||||||
raw_display,
|
raw_display,
|
||||||
(inner.width as f32 / scale).max(1.0),
|
(inner.width as f32 / scale).max(1.0),
|
||||||
(inner.height as f32 / scale).max(1.0),
|
(inner.height as f32 / scale).max(1.0),
|
||||||
scale,
|
scale,
|
||||||
)
|
) {
|
||||||
.expect("layers: create viewport handle");
|
Some(h) => h,
|
||||||
|
None => {
|
||||||
|
tracing::error!("new_from_raw returned None — wgpu surface failed");
|
||||||
|
event_loop.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tracing::info!("viewport handle ready");
|
||||||
|
|
||||||
self.window = Some(window);
|
self.window = Some(window);
|
||||||
self.handle = Some(handle);
|
self.handle = Some(handle);
|
||||||
|
|
@ -239,15 +255,6 @@ fn encode_modifiers(mods: ModifiersState) -> u32 {
|
||||||
bits
|
bits
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_logging() {
|
|
||||||
use tracing_subscriber::EnvFilter;
|
|
||||||
let _ = tracing_subscriber::fmt()
|
|
||||||
.with_env_filter(
|
|
||||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info,layers=info")),
|
|
||||||
)
|
|
||||||
.try_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn apply_win11_chrome(raw_window: &raw_window_handle::RawWindowHandle) {
|
fn apply_win11_chrome(raw_window: &raw_window_handle::RawWindowHandle) {
|
||||||
use raw_window_handle::RawWindowHandle;
|
use raw_window_handle::RawWindowHandle;
|
||||||
|
|
|
||||||
10
src/ffi.rs
10
src/ffi.rs
|
|
@ -663,6 +663,16 @@ fn dump_invocation_context() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Native-shell setup used by non-FFI entry points (winit binary on Windows / Linux).
|
||||||
|
/// Creates log + state dirs, initialises file-based tracing, preloads colours.
|
||||||
|
pub fn init_native_shell(plugin_root: Option<&std::path::Path>) -> anyhow::Result<()> {
|
||||||
|
paths::create_dirs_if_missing()?;
|
||||||
|
let _ = init_logging();
|
||||||
|
dump_invocation_context();
|
||||||
|
crate::ui::colors::init(plugin_root);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
fn init_logging() -> anyhow::Result<()> {
|
fn init_logging() -> anyhow::Result<()> {
|
||||||
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue