fmt
This commit is contained in:
@@ -19,8 +19,8 @@ use wlx_common::{audio, dash_interface::BoxDashInterface, timestep::Timestep};
|
||||
use crate::{
|
||||
assets, settings,
|
||||
tab::{
|
||||
apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, processes::TabProcesses, settings::TabSettings,
|
||||
Tab, TabType,
|
||||
Tab, TabType, apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, processes::TabProcesses,
|
||||
settings::TabSettings,
|
||||
},
|
||||
util::{
|
||||
popup_manager::{MountPopupParams, PopupManager, PopupManagerParams},
|
||||
|
||||
@@ -15,9 +15,9 @@ use wgui::{
|
||||
taffy::{self, prelude::length},
|
||||
task::Tasks,
|
||||
widget::{
|
||||
ConstructEssentials,
|
||||
div::WidgetDiv,
|
||||
label::{WidgetLabel, WidgetLabelParams},
|
||||
ConstructEssentials,
|
||||
},
|
||||
};
|
||||
use wlx_common::{dash_interface::BoxDashInterface, desktop_finder::DesktopEntry};
|
||||
|
||||
@@ -12,8 +12,8 @@ use wgui::{
|
||||
taffy::{self, prelude::length},
|
||||
task::Tasks,
|
||||
widget::{
|
||||
label::{WidgetLabel, WidgetLabelParams},
|
||||
ConstructEssentials,
|
||||
label::{WidgetLabel, WidgetLabelParams},
|
||||
},
|
||||
};
|
||||
use wlx_common::dash_interface::BoxDashInterface;
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
use std::{cell::RefCell, rc::{Rc, Weak}};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
rc::{Rc, Weak},
|
||||
};
|
||||
use taffy::{
|
||||
prelude::{length, percent},
|
||||
AlignItems,
|
||||
prelude::{length, percent},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
animation::{Animation, AnimationEasing},
|
||||
components::{radio_group::ComponentRadioGroup, Component, ComponentBase, ComponentTrait, RefreshData},
|
||||
components::{Component, ComponentBase, ComponentTrait, RefreshData, radio_group::ComponentRadioGroup},
|
||||
drawing::Color,
|
||||
event::{CallbackDataCommon, EventListenerCollection, EventListenerID, EventListenerKind},
|
||||
i18n::Translation,
|
||||
layout::{self, WidgetID, WidgetPair},
|
||||
renderer_vk::text::{FontWeight, TextStyle},
|
||||
widget::{
|
||||
ConstructEssentials, EventResult,
|
||||
label::{WidgetLabel, WidgetLabelParams},
|
||||
rectangle::{WidgetRectangle, WidgetRectangleParams},
|
||||
util::WLength,
|
||||
ConstructEssentials, EventResult,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -54,7 +57,7 @@ struct State {
|
||||
hovered: bool,
|
||||
down: bool,
|
||||
on_toggle: Option<CheckboxToggleCallback>,
|
||||
self_ref: Weak<ComponentCheckbox>,
|
||||
self_ref: Weak<ComponentCheckbox>,
|
||||
}
|
||||
|
||||
#[allow(clippy::struct_field_names)]
|
||||
@@ -128,7 +131,6 @@ impl ComponentCheckbox {
|
||||
self.state.borrow_mut().checked = checked;
|
||||
}
|
||||
|
||||
|
||||
pub fn on_toggle(&self, func: CheckboxToggleCallback) {
|
||||
self.state.borrow_mut().on_toggle = Some(func);
|
||||
}
|
||||
@@ -246,19 +248,27 @@ fn register_event_mouse_release(
|
||||
if state.down {
|
||||
state.down = false;
|
||||
|
||||
if let Some(self_ref) = state.self_ref.upgrade() && let Some(radio) = data.radio_group.as_ref().and_then(|r| r.upgrade()) {
|
||||
if let Some(self_ref) = state.self_ref.upgrade()
|
||||
&& let Some(radio) = data.radio_group.as_ref().and_then(|r| r.upgrade())
|
||||
{
|
||||
radio.set_selected_internal(common, &self_ref)?;
|
||||
state.checked = true; // can't uncheck radiobox by clicking the checked box again
|
||||
} else {
|
||||
state.checked = !state.checked;
|
||||
}
|
||||
}
|
||||
|
||||
set_box_checked(&common.state.widgets, &data, state.checked);
|
||||
|
||||
if state.hovered
|
||||
&& let Some(on_toggle) = &state.on_toggle
|
||||
{
|
||||
on_toggle(common, CheckboxToggleEvent { checked: state.checked, value: data.value.clone() })?;
|
||||
on_toggle(
|
||||
common,
|
||||
CheckboxToggleEvent {
|
||||
checked: state.checked,
|
||||
value: data.value.clone(),
|
||||
},
|
||||
)?;
|
||||
}
|
||||
Ok(EventResult::Consumed)
|
||||
} else {
|
||||
@@ -292,12 +302,12 @@ pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Resul
|
||||
};
|
||||
//style.align_self = Some(taffy::AlignSelf::Start); // do not stretch self to the parent
|
||||
style.gap = length(4.0);
|
||||
|
||||
|
||||
let (round_5, round_8) = if params.radio_group.is_some() {
|
||||
(WLength::Percent(1.0), WLength::Percent(1.0))
|
||||
} else {
|
||||
(WLength::Units(5.0), WLength::Units(8.0))
|
||||
};
|
||||
(WLength::Units(5.0), WLength::Units(8.0))
|
||||
};
|
||||
|
||||
let globals = ess.layout.state.globals.clone();
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ use std::{cell::RefCell, rc::Rc};
|
||||
use taffy::Style;
|
||||
|
||||
use crate::{
|
||||
components::{checkbox::ComponentCheckbox, Component, ComponentBase, ComponentTrait, RefreshData},
|
||||
components::{Component, ComponentBase, ComponentTrait, RefreshData, checkbox::ComponentCheckbox},
|
||||
event::CallbackDataCommon,
|
||||
layout::WidgetPair,
|
||||
widget::{div::WidgetDiv, ConstructEssentials},
|
||||
widget::{ConstructEssentials, div::WidgetDiv},
|
||||
};
|
||||
|
||||
pub struct RadioValueChangeEvent {
|
||||
|
||||
@@ -10,8 +10,8 @@ use crate::{
|
||||
globals::Globals,
|
||||
layout::Widget,
|
||||
renderer_vk::text::{
|
||||
custom_glyph::{CustomGlyph, CustomGlyphData},
|
||||
TextShadow,
|
||||
custom_glyph::{CustomGlyph, CustomGlyphData},
|
||||
},
|
||||
stack::{self, ScissorBoundary, ScissorStack, TransformStack},
|
||||
widget::{self, ScrollbarInfo, WidgetState},
|
||||
|
||||
@@ -13,12 +13,12 @@ use vulkano::{
|
||||
view::ImageView,
|
||||
},
|
||||
pipeline::{
|
||||
graphics::{self, vertex_input::Vertex, viewport::Viewport},
|
||||
Pipeline, PipelineBindPoint,
|
||||
graphics::{self, vertex_input::Vertex, viewport::Viewport},
|
||||
},
|
||||
};
|
||||
|
||||
use super::{pipeline::WGfxPipeline, WGfx};
|
||||
use super::{WGfx, pipeline::WGfxPipeline};
|
||||
|
||||
pub struct WGfxPass<V> {
|
||||
pub command_buffer: Arc<SecondaryAutoCommandBuffer>,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use std::{marker::PhantomData, ops::Range, sync::Arc};
|
||||
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use vulkano::{
|
||||
buffer::{
|
||||
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
||||
BufferContents, BufferUsage, Subbuffer,
|
||||
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
|
||||
},
|
||||
descriptor_set::{
|
||||
layout::{DescriptorBindingFlags, DescriptorSetLayoutCreateFlags},
|
||||
DescriptorSet, WriteDescriptorSet,
|
||||
layout::{DescriptorBindingFlags, DescriptorSetLayoutCreateFlags},
|
||||
},
|
||||
format::Format,
|
||||
image::{
|
||||
@@ -17,8 +17,9 @@ use vulkano::{
|
||||
},
|
||||
memory::allocator::MemoryTypeFilter,
|
||||
pipeline::{
|
||||
DynamicState, GraphicsPipeline, Pipeline, PipelineLayout,
|
||||
graphics::{
|
||||
self,
|
||||
self, GraphicsPipelineCreateInfo,
|
||||
color_blend::{AttachmentBlend, ColorBlendAttachmentState, ColorBlendState},
|
||||
input_assembly::{InputAssemblyState, PrimitiveTopology},
|
||||
multisample::MultisampleState,
|
||||
@@ -26,15 +27,13 @@ use vulkano::{
|
||||
subpass::PipelineRenderingCreateInfo,
|
||||
vertex_input::{Vertex, VertexDefinition, VertexInputState},
|
||||
viewport::ViewportState,
|
||||
GraphicsPipelineCreateInfo,
|
||||
},
|
||||
layout::PipelineDescriptorSetLayoutCreateInfo,
|
||||
DynamicState, GraphicsPipeline, Pipeline, PipelineLayout,
|
||||
},
|
||||
shader::{EntryPoint, ShaderModule},
|
||||
};
|
||||
|
||||
use super::{pass::WGfxPass, WGfx};
|
||||
use super::{WGfx, pass::WGfxPass};
|
||||
|
||||
pub struct WGfxPipeline<V> {
|
||||
pub graphics: Arc<WGfx>,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::{
|
||||
components::{checkbox, radio_group::ComponentRadioGroup, Component},
|
||||
components::{Component, checkbox, radio_group::ComponentRadioGroup},
|
||||
i18n::Translation,
|
||||
layout::WidgetID,
|
||||
parser::{
|
||||
parse_check_f32, parse_check_i32, process_component, style::parse_style, AttribPair, Fetchable, ParserContext,
|
||||
AttribPair, Fetchable, ParserContext, parse_check_f32, parse_check_i32, process_component, style::parse_style,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
components::{radio_group, Component},
|
||||
components::{Component, radio_group},
|
||||
layout::WidgetID,
|
||||
parser::{parse_children, process_component, style::parse_style, AttribPair, ParserContext, ParserFile},
|
||||
parser::{AttribPair, ParserContext, ParserFile, parse_children, process_component, style::parse_style},
|
||||
};
|
||||
|
||||
pub fn parse_component_radio_group<'a>(
|
||||
|
||||
@@ -10,9 +10,24 @@ mod widget_rectangle;
|
||||
mod widget_sprite;
|
||||
|
||||
use crate::{
|
||||
assets::{normalize_path, AssetPath, AssetPathOwned}, components::{Component, ComponentWeak}, drawing::{self}, globals::WguiGlobals, layout::{Layout, LayoutParams, LayoutState, Widget, WidgetID, WidgetMap, WidgetPair}, log::LogErr, parser::{
|
||||
component_button::parse_component_button, component_checkbox::{parse_component_checkbox, CheckboxKind}, component_radio_group::parse_component_radio_group, component_slider::parse_component_slider, widget_div::parse_widget_div, widget_image::parse_widget_image, widget_label::parse_widget_label, widget_rectangle::parse_widget_rectangle, widget_sprite::parse_widget_sprite
|
||||
}, widget::ConstructEssentials
|
||||
assets::{AssetPath, AssetPathOwned, normalize_path},
|
||||
components::{Component, ComponentWeak},
|
||||
drawing::{self},
|
||||
globals::WguiGlobals,
|
||||
layout::{Layout, LayoutParams, LayoutState, Widget, WidgetID, WidgetMap, WidgetPair},
|
||||
log::LogErr,
|
||||
parser::{
|
||||
component_button::parse_component_button,
|
||||
component_checkbox::{CheckboxKind, parse_component_checkbox},
|
||||
component_radio_group::parse_component_radio_group,
|
||||
component_slider::parse_component_slider,
|
||||
widget_div::parse_widget_div,
|
||||
widget_image::parse_widget_image,
|
||||
widget_label::parse_widget_label,
|
||||
widget_rectangle::parse_widget_rectangle,
|
||||
widget_sprite::parse_widget_sprite,
|
||||
},
|
||||
widget::ConstructEssentials,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use ouroboros::self_referencing;
|
||||
@@ -903,10 +918,20 @@ fn parse_child<'a>(
|
||||
new_widget_id = Some(parse_component_slider(ctx, parent_id, &attribs)?);
|
||||
}
|
||||
"CheckBox" => {
|
||||
new_widget_id = Some(parse_component_checkbox(ctx, parent_id, &attribs, CheckboxKind::CheckBox)?);
|
||||
new_widget_id = Some(parse_component_checkbox(
|
||||
ctx,
|
||||
parent_id,
|
||||
&attribs,
|
||||
CheckboxKind::CheckBox,
|
||||
)?);
|
||||
}
|
||||
"RadioBox" => {
|
||||
new_widget_id = Some(parse_component_checkbox(ctx, parent_id, &attribs, CheckboxKind::RadioBox)?);
|
||||
new_widget_id = Some(parse_component_checkbox(
|
||||
ctx,
|
||||
parent_id,
|
||||
&attribs,
|
||||
CheckboxKind::RadioBox,
|
||||
)?);
|
||||
}
|
||||
"RadioGroup" => {
|
||||
new_widget_id = Some(parse_component_radio_group(file, ctx, child_node, parent_id, &attribs)?);
|
||||
@@ -1104,7 +1129,10 @@ fn get_doc_from_asset_path(
|
||||
allow_dtd: true,
|
||||
..Default::default()
|
||||
};
|
||||
roxmltree::Document::parse_with_options(xml, opt).context("Unable to parse XML").log_err_with(&asset_path).unwrap()
|
||||
roxmltree::Document::parse_with_options(xml, opt)
|
||||
.context("Unable to parse XML")
|
||||
.log_err_with(&asset_path)
|
||||
.unwrap()
|
||||
}));
|
||||
|
||||
let root = document.borrow_doc().root();
|
||||
|
||||
@@ -6,8 +6,8 @@ use taffy::{
|
||||
use crate::{
|
||||
drawing,
|
||||
parser::{
|
||||
is_percent, parse_color_hex, parse_f32, parse_percent, parse_size_unit, parse_val, print_invalid_attrib,
|
||||
print_invalid_value, AttribPair,
|
||||
AttribPair, is_percent, parse_color_hex, parse_f32, parse_percent, parse_size_unit, parse_val,
|
||||
print_invalid_attrib, print_invalid_value,
|
||||
},
|
||||
renderer_vk::text::{FontWeight, HorizontalAlign, TextStyle},
|
||||
widget::util::WLength,
|
||||
|
||||
@@ -2,9 +2,8 @@ use crate::{
|
||||
assets::AssetPath,
|
||||
layout::WidgetID,
|
||||
parser::{
|
||||
parse_children, parse_widget_universal, print_invalid_attrib,
|
||||
AttribPair, ParserContext, ParserFile, parse_children, parse_widget_universal, print_invalid_attrib,
|
||||
style::{parse_color, parse_round, parse_style},
|
||||
AttribPair, ParserContext, ParserFile,
|
||||
},
|
||||
renderer_vk::text::custom_glyph::CustomGlyphData,
|
||||
widget::image::{WidgetImage, WidgetImageParams},
|
||||
|
||||
@@ -2,9 +2,8 @@ use crate::{
|
||||
drawing::GradientMode,
|
||||
layout::WidgetID,
|
||||
parser::{
|
||||
parse_children, parse_widget_universal, print_invalid_attrib,
|
||||
AttribPair, ParserContext, ParserFile, parse_children, parse_widget_universal, print_invalid_attrib,
|
||||
style::{parse_color, parse_round, parse_style},
|
||||
AttribPair, ParserContext, ParserFile,
|
||||
},
|
||||
widget::rectangle::{WidgetRectangle, WidgetRectangleParams},
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
assets::AssetPath,
|
||||
layout::WidgetID,
|
||||
parser::{parse_children, parse_widget_universal, style::parse_style, AttribPair, ParserContext, ParserFile},
|
||||
parser::{AttribPair, ParserContext, ParserFile, parse_children, parse_widget_universal, style::parse_style},
|
||||
renderer_vk::text::custom_glyph::CustomGlyphData,
|
||||
widget::sprite::{WidgetSprite, WidgetSpriteParams},
|
||||
};
|
||||
|
||||
@@ -14,10 +14,10 @@ use vulkano::{
|
||||
use crate::{
|
||||
drawing::{Boundary, ImagePrimitive},
|
||||
gfx::{
|
||||
BLEND_ALPHA, WGfx,
|
||||
cmd::GfxCommandBuffer,
|
||||
pass::WGfxPass,
|
||||
pipeline::{WGfxPipeline, WPipelineCreateInfo},
|
||||
WGfx, BLEND_ALPHA,
|
||||
},
|
||||
renderer_vk::{
|
||||
model_buffer::ModelBuffer,
|
||||
|
||||
@@ -10,10 +10,10 @@ use vulkano::{
|
||||
use crate::{
|
||||
drawing::{Boundary, Rectangle},
|
||||
gfx::{
|
||||
BLEND_ALPHA, WGfx,
|
||||
cmd::GfxCommandBuffer,
|
||||
pass::WGfxPass,
|
||||
pipeline::{WGfxPipeline, WPipelineCreateInfo},
|
||||
WGfx, BLEND_ALPHA,
|
||||
},
|
||||
renderer_vk::model_buffer::ModelBuffer,
|
||||
};
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::{
|
||||
f32,
|
||||
hash::{DefaultHasher, Hasher},
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
Arc, Weak,
|
||||
atomic::{AtomicUsize, Ordering},
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
ContentType, FontSystem, GlyphDetails, GpuCacheStatus, SwashCache, TextArea,
|
||||
custom_glyph::{CustomGlyphCacheKey, RasterizeCustomGlyphRequest, RasterizedCustomGlyph},
|
||||
text_atlas::{GlyphVertex, TextAtlas, TextPipeline},
|
||||
ContentType, FontSystem, GlyphDetails, GpuCacheStatus, SwashCache, TextArea,
|
||||
};
|
||||
use cosmic_text::{Color, SubpixelBin, SwashContent};
|
||||
use etagere::size2;
|
||||
|
||||
@@ -297,10 +297,10 @@ where
|
||||
width: 0,
|
||||
height: 0,
|
||||
drm_format: DrmFormat {
|
||||
code: DrmFourcc::Argb8888,
|
||||
modifier: DrmModifier::Invalid,
|
||||
},
|
||||
transform: Transform::Undefined,
|
||||
code: DrmFourcc::Argb8888,
|
||||
modifier: DrmModifier::Invalid,
|
||||
},
|
||||
transform: Transform::Undefined,
|
||||
})
|
||||
.state_changed({
|
||||
let name = name.clone();
|
||||
@@ -698,7 +698,7 @@ fn get_format_params(fmt: Option<(&DrmFourcc, &Vec<DrmModifier>)>) -> Object {
|
||||
}
|
||||
|
||||
fn fourcc_to_spa(fourcc: DrmFourcc) -> VideoFormat {
|
||||
match fourcc{
|
||||
match fourcc {
|
||||
DrmFourcc::Argb8888 => VideoFormat::BGRA,
|
||||
DrmFourcc::Abgr8888 => VideoFormat::RGBA,
|
||||
DrmFourcc::Xrgb8888 => VideoFormat::BGRx,
|
||||
|
||||
@@ -3,14 +3,13 @@ use std::{path::PathBuf, sync::LazyLock};
|
||||
const FALLBACK_CACHE_PATH: &str = "/tmp/wayvr_cache";
|
||||
|
||||
static CACHE_ROOT_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
|
||||
|
||||
if let Some(mut dir) = xdg::BaseDirectories::new().get_cache_home() {
|
||||
if let Some(mut dir) = xdg::BaseDirectories::new().get_cache_home() {
|
||||
dir.push("wayvr");
|
||||
return dir;
|
||||
}
|
||||
//Return fallback cache path
|
||||
log::error!("Err: Failed to find cache path, using {FALLBACK_CACHE_PATH}");
|
||||
PathBuf::from(FALLBACK_CACHE_PATH) // Panics if neither $XDG_CACHE_HOME nor $HOME is set
|
||||
PathBuf::from(FALLBACK_CACHE_PATH) // Panics if neither $XDG_CACHE_HOME nor $HOME is set
|
||||
});
|
||||
|
||||
fn get_cache_root() -> PathBuf {
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
use std::{
|
||||
collections::{HashMap, HashSet}, ffi::OsStr, fmt::Debug, fs::exists, path::Path, rc::Rc, sync::Arc, thread::JoinHandle,
|
||||
collections::{HashMap, HashSet},
|
||||
ffi::OsStr,
|
||||
fmt::Debug,
|
||||
fs::exists,
|
||||
path::Path,
|
||||
rc::Rc,
|
||||
sync::Arc,
|
||||
thread::JoinHandle,
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use crate::cache_dir;
|
||||
use ini::Ini;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use walkdir::WalkDir;
|
||||
use crate::cache_dir;
|
||||
|
||||
struct DesktopEntryOwned {
|
||||
exec_path: String,
|
||||
@@ -50,8 +57,8 @@ struct DesktopFinderParams {
|
||||
|
||||
pub struct DesktopFinder {
|
||||
params: Arc<DesktopFinderParams>,
|
||||
entry_cache: HashMap<String,DesktopEntry>,
|
||||
bg_task: Option<JoinHandle<HashMap<String,DesktopEntryOwned>>>,
|
||||
entry_cache: HashMap<String, DesktopEntry>,
|
||||
bg_task: Option<JoinHandle<HashMap<String, DesktopEntryOwned>>>,
|
||||
}
|
||||
|
||||
impl DesktopFinder {
|
||||
@@ -131,7 +138,10 @@ impl DesktopFinder {
|
||||
}
|
||||
|
||||
let file_name = entry.file_name().to_string_lossy();
|
||||
let Some(app_id) = Path::new(entry.file_name()).file_stem().map(|x| x.to_string_lossy().to_string()) else {
|
||||
let Some(app_id) = Path::new(entry.file_name())
|
||||
.file_stem()
|
||||
.map(|x| x.to_string_lossy().to_string())
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -223,12 +233,15 @@ impl DesktopFinder {
|
||||
|
||||
known_files.insert(file_name.to_string());
|
||||
|
||||
entries.insert(app_id, DesktopEntryOwned {
|
||||
app_name: String::from(app_name),
|
||||
exec_path: String::from(exec_path),
|
||||
exec_args: exec_args.join(" "),
|
||||
icon_path,
|
||||
});
|
||||
entries.insert(
|
||||
app_id,
|
||||
DesktopEntryOwned {
|
||||
app_name: String::from(app_name),
|
||||
exec_path: String::from(exec_path),
|
||||
exec_args: exec_args.join(" "),
|
||||
icon_path,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user