get rid of once_cell
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -5328,7 +5328,6 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"log-panics",
|
"log-panics",
|
||||||
"mint",
|
"mint",
|
||||||
"once_cell",
|
|
||||||
"openxr",
|
"openxr",
|
||||||
"ovr_overlay",
|
"ovr_overlay",
|
||||||
"regex",
|
"regex",
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ json = { version = "0.12.4", optional = true }
|
|||||||
json5 = "0.4.1"
|
json5 = "0.4.1"
|
||||||
libc = "0.2.155"
|
libc = "0.2.155"
|
||||||
log = "0.4.21"
|
log = "0.4.21"
|
||||||
once_cell = "1.19.0"
|
|
||||||
openxr = { git = "https://github.com/galister/openxrs", rev = "af4a55d", features = [
|
openxr = { git = "https://github.com/galister/openxrs", rev = "af4a55d", features = [
|
||||||
"linked",
|
"linked",
|
||||||
"mint",
|
"mint",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::{Arc, LazyLock};
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
#[cfg(feature = "openxr")]
|
#[cfg(feature = "openxr")]
|
||||||
use openxr as xr;
|
use openxr as xr;
|
||||||
|
|
||||||
@@ -319,8 +318,8 @@ where
|
|||||||
.any(|o| o.state.show_hide && o.state.want_visible);
|
.any(|o| o.state.show_hide && o.state.want_visible);
|
||||||
|
|
||||||
if !any_shown {
|
if !any_shown {
|
||||||
static ANCHOR_LOCAL: Lazy<Affine3A> =
|
static ANCHOR_LOCAL: LazyLock<Affine3A> =
|
||||||
Lazy::new(|| Affine3A::from_translation(Vec3::NEG_Z));
|
LazyLock::new(|| Affine3A::from_translation(Vec3::NEG_Z));
|
||||||
let hmd = snap_upright(app.input_state.hmd, Vec3A::Y);
|
let hmd = snap_upright(app.input_state.hmd, Vec3A::Y);
|
||||||
app.anchor = hmd * *ANCHOR_LOCAL;
|
app.anchor = hmd * *ANCHOR_LOCAL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
use std::{f32::consts::PI, fs::File, sync::Arc};
|
use std::{
|
||||||
|
f32::consts::PI,
|
||||||
|
fs::File,
|
||||||
|
sync::{Arc, LazyLock},
|
||||||
|
};
|
||||||
|
|
||||||
use glam::{Quat, Vec3A};
|
use glam::{Quat, Vec3A};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use openxr::{self as xr, CompositionLayerFlags};
|
use openxr::{self as xr, CompositionLayerFlags};
|
||||||
use vulkano::{
|
use vulkano::{
|
||||||
command_buffer::CommandBufferUsage, image::view::ImageView,
|
command_buffer::CommandBufferUsage, image::view::ImageView,
|
||||||
@@ -186,7 +189,7 @@ impl Skybox {
|
|||||||
const HI_VERT_ANGLE: f32 = 0.5 * PI;
|
const HI_VERT_ANGLE: f32 = 0.5 * PI;
|
||||||
const LO_VERT_ANGLE: f32 = -0.5 * PI;
|
const LO_VERT_ANGLE: f32 = -0.5 * PI;
|
||||||
|
|
||||||
static GRID_POSE: Lazy<xr::Posef> = Lazy::new(|| {
|
static GRID_POSE: LazyLock<xr::Posef> = LazyLock::new(|| {
|
||||||
translation_rotation_to_posef(Vec3A::ZERO, Quat::from_rotation_x(PI * -0.5))
|
translation_rotation_to_posef(Vec3A::ZERO, Quat::from_rotation_x(PI * -0.5))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use log::error;
|
use log::error;
|
||||||
use once_cell::sync::Lazy;
|
use std::{path::PathBuf, sync::LazyLock};
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
pub enum ConfigRoot {
|
pub enum ConfigRoot {
|
||||||
Generic,
|
Generic,
|
||||||
@@ -10,16 +9,14 @@ pub enum ConfigRoot {
|
|||||||
|
|
||||||
const FALLBACK_CONFIG_PATH: &str = "/tmp/wlxoverlay";
|
const FALLBACK_CONFIG_PATH: &str = "/tmp/wlxoverlay";
|
||||||
|
|
||||||
static CONFIG_ROOT_PATH: Lazy<PathBuf> = Lazy::new(|| {
|
static CONFIG_ROOT_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
|
||||||
if let Ok(xdg_dirs) = xdg::BaseDirectories::new() {
|
if let Ok(xdg_dirs) = xdg::BaseDirectories::new() {
|
||||||
let mut dir = xdg_dirs.get_config_home();
|
let mut dir = xdg_dirs.get_config_home();
|
||||||
dir.push("wlxoverlay");
|
dir.push("wlxoverlay");
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
//Return fallback config path
|
//Return fallback config path
|
||||||
error!(
|
error!("Err: Failed to find config path, using {FALLBACK_CONFIG_PATH}");
|
||||||
"Err: Failed to find config path, using {FALLBACK_CONFIG_PATH}"
|
|
||||||
);
|
|
||||||
PathBuf::from(FALLBACK_CONFIG_PATH)
|
PathBuf::from(FALLBACK_CONFIG_PATH)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
use glam::Vec4;
|
use glam::Vec4;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
pub mod canvas;
|
pub mod canvas;
|
||||||
pub mod font;
|
pub mod font;
|
||||||
pub mod modular;
|
pub mod modular;
|
||||||
|
|
||||||
pub type GuiColor = Vec4;
|
pub type GuiColor = Vec4;
|
||||||
pub static FALLBACK_COLOR: Lazy<GuiColor> = Lazy::new(|| Vec4::new(1., 0., 1., 1.));
|
pub static FALLBACK_COLOR: LazyLock<GuiColor> = LazyLock::new(|| Vec4::new(1., 0., 1., 1.));
|
||||||
|
|
||||||
// Parses a color from a HTML hex string
|
// Parses a color from a HTML hex string
|
||||||
pub fn color_parse(html_hex: &str) -> anyhow::Result<GuiColor> {
|
pub fn color_parse(html_hex: &str) -> anyhow::Result<GuiColor> {
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ use input_linux::{
|
|||||||
UInputHandle,
|
UInputHandle,
|
||||||
};
|
};
|
||||||
use libc::{input_event, timeval};
|
use libc::{input_event, timeval};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
|
use std::sync::LazyLock;
|
||||||
use std::{fs::File, sync::atomic::AtomicBool};
|
use std::{fs::File, sync::atomic::AtomicBool};
|
||||||
use strum::{EnumIter, EnumString, IntoEnumIterator};
|
use strum::{EnumIter, EnumString, IntoEnumIterator};
|
||||||
use xkbcommon::xkb;
|
use xkbcommon::xkb;
|
||||||
@@ -476,7 +476,7 @@ pub enum VirtualKey {
|
|||||||
XF86Search = 225,
|
XF86Search = 225,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static KEYS_TO_MODS: Lazy<IdMap<VirtualKey, KeyModifier>> = Lazy::new(|| {
|
pub static KEYS_TO_MODS: LazyLock<IdMap<VirtualKey, KeyModifier>> = LazyLock::new(|| {
|
||||||
idmap! {
|
idmap! {
|
||||||
VirtualKey::LShift => SHIFT,
|
VirtualKey::LShift => SHIFT,
|
||||||
VirtualKey::RShift => SHIFT,
|
VirtualKey::RShift => SHIFT,
|
||||||
@@ -491,7 +491,7 @@ pub static KEYS_TO_MODS: Lazy<IdMap<VirtualKey, KeyModifier>> = Lazy::new(|| {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
pub static MODS_TO_KEYS: Lazy<IdMap<KeyModifier, Vec<VirtualKey>>> = Lazy::new(|| {
|
pub static MODS_TO_KEYS: LazyLock<IdMap<KeyModifier, Vec<VirtualKey>>> = LazyLock::new(|| {
|
||||||
idmap! {
|
idmap! {
|
||||||
SHIFT => vec![VirtualKey::LShift, VirtualKey::RShift],
|
SHIFT => vec![VirtualKey::LShift, VirtualKey::RShift],
|
||||||
CAPS_LOCK => vec![VirtualKey::Caps],
|
CAPS_LOCK => vec![VirtualKey::Caps],
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
use glam::Vec3A;
|
use glam::Vec3A;
|
||||||
use once_cell::sync::Lazy;
|
use std::sync::{Arc, LazyLock};
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use crate::backend::overlay::{OverlayData, OverlayState, RelativeTo, Z_ORDER_ANCHOR};
|
use crate::backend::overlay::{OverlayData, OverlayState, RelativeTo, Z_ORDER_ANCHOR};
|
||||||
use crate::config::{load_known_yaml, ConfigType};
|
use crate::config::{load_known_yaml, ConfigType};
|
||||||
use crate::gui::modular::{modular_canvas, ModularUiConfig};
|
use crate::gui::modular::{modular_canvas, ModularUiConfig};
|
||||||
use crate::state::AppState;
|
use crate::state::AppState;
|
||||||
|
|
||||||
pub static ANCHOR_NAME: Lazy<Arc<str>> = Lazy::new(|| Arc::from("anchor"));
|
pub static ANCHOR_NAME: LazyLock<Arc<str>> = LazyLock::new(|| Arc::from("anchor"));
|
||||||
|
|
||||||
pub fn create_anchor<O>(state: &mut AppState) -> anyhow::Result<OverlayData<O>>
|
pub fn create_anchor<O>(state: &mut AppState) -> anyhow::Result<OverlayData<O>>
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::{
|
|||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
process::{Child, Command},
|
process::{Child, Command},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
sync::Arc,
|
sync::{Arc, LazyLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -25,7 +25,6 @@ use crate::{
|
|||||||
state::{AppState, KeyboardFocus},
|
state::{AppState, KeyboardFocus},
|
||||||
};
|
};
|
||||||
use glam::{vec2, vec3a, Affine2, Vec4};
|
use glam::{vec2, vec3a, Affine2, Vec4};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vulkano::image::view::ImageView;
|
use vulkano::image::view::ImageView;
|
||||||
@@ -378,10 +377,10 @@ enum KeyButtonData {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
static LAYOUT: Lazy<Layout> = Lazy::new(Layout::load_from_disk);
|
static LAYOUT: LazyLock<Layout> = LazyLock::new(Layout::load_from_disk);
|
||||||
|
|
||||||
static MACRO_REGEX: Lazy<Regex> =
|
static MACRO_REGEX: LazyLock<Regex> =
|
||||||
Lazy::new(|| Regex::new(r"^([A-Za-z0-9_-]+)(?: +(UP|DOWN))?$").unwrap()); // want panic
|
LazyLock::new(|| Regex::new(r"^([A-Za-z0-9_-]+)(?: +(UP|DOWN))?$").unwrap()); // want panic
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, Deserialize, Serialize)]
|
#[derive(Debug, Default, Clone, Copy, Deserialize, Serialize)]
|
||||||
#[repr(usize)]
|
#[repr(usize)]
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
use core::slice;
|
use core::slice;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
f32::consts::PI,
|
f32::consts::PI,
|
||||||
ptr,
|
ptr,
|
||||||
sync::{atomic::AtomicU64, Arc},
|
sync::{atomic::AtomicU64, Arc, LazyLock},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use vulkano::{
|
use vulkano::{
|
||||||
@@ -16,10 +15,7 @@ use vulkano::{
|
|||||||
use wlx_capture::frame as wlx_frame;
|
use wlx_capture::frame as wlx_frame;
|
||||||
|
|
||||||
use wlx_capture::{
|
use wlx_capture::{
|
||||||
frame::{
|
frame::{FrameFormat, MouseMeta, WlxFrame},
|
||||||
DrmFormat, FrameFormat, MouseMeta, WlxFrame, DRM_FORMAT_ABGR2101010, DRM_FORMAT_ABGR8888,
|
|
||||||
DRM_FORMAT_ARGB8888, DRM_FORMAT_XBGR2101010, DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888,
|
|
||||||
},
|
|
||||||
WlxCapture,
|
WlxCapture,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,8 +53,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
config::{def_pw_tokens, GeneralConfig, PwTokenMap},
|
config::{def_pw_tokens, GeneralConfig, PwTokenMap},
|
||||||
graphics::{
|
graphics::{
|
||||||
fourcc_to_vk, CommandBuffers, WlxCommandBuffer, WlxGraphics, WlxPipeline,
|
fourcc_to_vk, CommandBuffers, WlxCommandBuffer, WlxGraphics, WlxPipeline, SWAPCHAIN_FORMAT,
|
||||||
DRM_FORMAT_MOD_INVALID, SWAPCHAIN_FORMAT,
|
|
||||||
},
|
},
|
||||||
hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
|
hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
|
||||||
state::{AppSession, AppState, KeyboardFocus, ScreenMeta},
|
state::{AppSession, AppState, KeyboardFocus, ScreenMeta},
|
||||||
@@ -72,7 +67,7 @@ pub(crate) type WlxClientAlias = ();
|
|||||||
|
|
||||||
const CURSOR_SIZE: f32 = 16. / 1440.;
|
const CURSOR_SIZE: f32 = 16. / 1440.;
|
||||||
|
|
||||||
static START: Lazy<Instant> = Lazy::new(Instant::now);
|
static START: LazyLock<Instant> = LazyLock::new(Instant::now);
|
||||||
static NEXT_MOVE: AtomicU64 = AtomicU64::new(0);
|
static NEXT_MOVE: AtomicU64 = AtomicU64::new(0);
|
||||||
|
|
||||||
fn can_move() -> bool {
|
fn can_move() -> bool {
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
use std::{f32::consts::PI, ops::Add, sync::Arc, time::Instant};
|
use std::{
|
||||||
|
f32::consts::PI,
|
||||||
|
ops::Add,
|
||||||
|
sync::{Arc, LazyLock},
|
||||||
|
time::Instant,
|
||||||
|
};
|
||||||
|
|
||||||
use glam::{vec3a, Quat};
|
use glam::{vec3a, Quat};
|
||||||
use idmap_derive::IntegerId;
|
use idmap_derive::IntegerId;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -18,7 +22,7 @@ use crate::{
|
|||||||
const FONT_SIZE: isize = 16;
|
const FONT_SIZE: isize = 16;
|
||||||
const PADDING: (f32, f32) = (25., 7.);
|
const PADDING: (f32, f32) = (25., 7.);
|
||||||
const PIXELS_TO_METERS: f32 = 1. / 2000.;
|
const PIXELS_TO_METERS: f32 = 1. / 2000.;
|
||||||
static TOAST_NAME: Lazy<Arc<str>> = Lazy::new(|| "toast".into());
|
static TOAST_NAME: LazyLock<Arc<str>> = LazyLock::new(|| "toast".into());
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||||
pub enum DisplayMethod {
|
pub enum DisplayMethod {
|
||||||
|
|||||||
Reference in New Issue
Block a user