This commit is contained in:
galister
2026-01-05 20:52:34 +09:00
parent fd9becc398
commit 164e9764eb
22 changed files with 115 additions and 68 deletions

View File

@@ -19,8 +19,8 @@ use wlx_common::{audio, dash_interface::BoxDashInterface, timestep::Timestep};
use crate::{ use crate::{
assets, settings, assets, settings,
tab::{ tab::{
apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, processes::TabProcesses, settings::TabSettings, Tab, TabType, apps::TabApps, games::TabGames, home::TabHome, monado::TabMonado, processes::TabProcesses,
Tab, TabType, settings::TabSettings,
}, },
util::{ util::{
popup_manager::{MountPopupParams, PopupManager, PopupManagerParams}, popup_manager::{MountPopupParams, PopupManager, PopupManagerParams},

View File

@@ -15,9 +15,9 @@ use wgui::{
taffy::{self, prelude::length}, taffy::{self, prelude::length},
task::Tasks, task::Tasks,
widget::{ widget::{
ConstructEssentials,
div::WidgetDiv, div::WidgetDiv,
label::{WidgetLabel, WidgetLabelParams}, label::{WidgetLabel, WidgetLabelParams},
ConstructEssentials,
}, },
}; };
use wlx_common::{dash_interface::BoxDashInterface, desktop_finder::DesktopEntry}; use wlx_common::{dash_interface::BoxDashInterface, desktop_finder::DesktopEntry};

View File

@@ -12,8 +12,8 @@ use wgui::{
taffy::{self, prelude::length}, taffy::{self, prelude::length},
task::Tasks, task::Tasks,
widget::{ widget::{
label::{WidgetLabel, WidgetLabelParams},
ConstructEssentials, ConstructEssentials,
label::{WidgetLabel, WidgetLabelParams},
}, },
}; };
use wlx_common::dash_interface::BoxDashInterface; use wlx_common::dash_interface::BoxDashInterface;

View File

@@ -1,22 +1,25 @@
use std::{cell::RefCell, rc::{Rc, Weak}}; use std::{
cell::RefCell,
rc::{Rc, Weak},
};
use taffy::{ use taffy::{
prelude::{length, percent},
AlignItems, AlignItems,
prelude::{length, percent},
}; };
use crate::{ use crate::{
animation::{Animation, AnimationEasing}, animation::{Animation, AnimationEasing},
components::{radio_group::ComponentRadioGroup, Component, ComponentBase, ComponentTrait, RefreshData}, components::{Component, ComponentBase, ComponentTrait, RefreshData, radio_group::ComponentRadioGroup},
drawing::Color, drawing::Color,
event::{CallbackDataCommon, EventListenerCollection, EventListenerID, EventListenerKind}, event::{CallbackDataCommon, EventListenerCollection, EventListenerID, EventListenerKind},
i18n::Translation, i18n::Translation,
layout::{self, WidgetID, WidgetPair}, layout::{self, WidgetID, WidgetPair},
renderer_vk::text::{FontWeight, TextStyle}, renderer_vk::text::{FontWeight, TextStyle},
widget::{ widget::{
ConstructEssentials, EventResult,
label::{WidgetLabel, WidgetLabelParams}, label::{WidgetLabel, WidgetLabelParams},
rectangle::{WidgetRectangle, WidgetRectangleParams}, rectangle::{WidgetRectangle, WidgetRectangleParams},
util::WLength, util::WLength,
ConstructEssentials, EventResult,
}, },
}; };
@@ -128,7 +131,6 @@ impl ComponentCheckbox {
self.state.borrow_mut().checked = checked; self.state.borrow_mut().checked = checked;
} }
pub fn on_toggle(&self, func: CheckboxToggleCallback) { pub fn on_toggle(&self, func: CheckboxToggleCallback) {
self.state.borrow_mut().on_toggle = Some(func); self.state.borrow_mut().on_toggle = Some(func);
} }
@@ -246,7 +248,9 @@ fn register_event_mouse_release(
if state.down { if state.down {
state.down = false; 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)?; radio.set_selected_internal(common, &self_ref)?;
state.checked = true; // can't uncheck radiobox by clicking the checked box again state.checked = true; // can't uncheck radiobox by clicking the checked box again
} else { } else {
@@ -258,7 +262,13 @@ fn register_event_mouse_release(
if state.hovered if state.hovered
&& let Some(on_toggle) = &state.on_toggle && 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) Ok(EventResult::Consumed)
} else { } else {

View File

@@ -3,10 +3,10 @@ use std::{cell::RefCell, rc::Rc};
use taffy::Style; use taffy::Style;
use crate::{ use crate::{
components::{checkbox::ComponentCheckbox, Component, ComponentBase, ComponentTrait, RefreshData}, components::{Component, ComponentBase, ComponentTrait, RefreshData, checkbox::ComponentCheckbox},
event::CallbackDataCommon, event::CallbackDataCommon,
layout::WidgetPair, layout::WidgetPair,
widget::{div::WidgetDiv, ConstructEssentials}, widget::{ConstructEssentials, div::WidgetDiv},
}; };
pub struct RadioValueChangeEvent { pub struct RadioValueChangeEvent {

View File

@@ -10,8 +10,8 @@ use crate::{
globals::Globals, globals::Globals,
layout::Widget, layout::Widget,
renderer_vk::text::{ renderer_vk::text::{
custom_glyph::{CustomGlyph, CustomGlyphData},
TextShadow, TextShadow,
custom_glyph::{CustomGlyph, CustomGlyphData},
}, },
stack::{self, ScissorBoundary, ScissorStack, TransformStack}, stack::{self, ScissorBoundary, ScissorStack, TransformStack},
widget::{self, ScrollbarInfo, WidgetState}, widget::{self, ScrollbarInfo, WidgetState},

View File

@@ -13,12 +13,12 @@ use vulkano::{
view::ImageView, view::ImageView,
}, },
pipeline::{ pipeline::{
graphics::{self, vertex_input::Vertex, viewport::Viewport},
Pipeline, PipelineBindPoint, Pipeline, PipelineBindPoint,
graphics::{self, vertex_input::Vertex, viewport::Viewport},
}, },
}; };
use super::{pipeline::WGfxPipeline, WGfx}; use super::{WGfx, pipeline::WGfxPipeline};
pub struct WGfxPass<V> { pub struct WGfxPass<V> {
pub command_buffer: Arc<SecondaryAutoCommandBuffer>, pub command_buffer: Arc<SecondaryAutoCommandBuffer>,

View File

@@ -1,14 +1,14 @@
use std::{marker::PhantomData, ops::Range, sync::Arc}; use std::{marker::PhantomData, ops::Range, sync::Arc};
use smallvec::{smallvec, SmallVec}; use smallvec::{SmallVec, smallvec};
use vulkano::{ use vulkano::{
buffer::{ buffer::{
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
BufferContents, BufferUsage, Subbuffer, BufferContents, BufferUsage, Subbuffer,
allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo},
}, },
descriptor_set::{ descriptor_set::{
layout::{DescriptorBindingFlags, DescriptorSetLayoutCreateFlags},
DescriptorSet, WriteDescriptorSet, DescriptorSet, WriteDescriptorSet,
layout::{DescriptorBindingFlags, DescriptorSetLayoutCreateFlags},
}, },
format::Format, format::Format,
image::{ image::{
@@ -17,8 +17,9 @@ use vulkano::{
}, },
memory::allocator::MemoryTypeFilter, memory::allocator::MemoryTypeFilter,
pipeline::{ pipeline::{
DynamicState, GraphicsPipeline, Pipeline, PipelineLayout,
graphics::{ graphics::{
self, self, GraphicsPipelineCreateInfo,
color_blend::{AttachmentBlend, ColorBlendAttachmentState, ColorBlendState}, color_blend::{AttachmentBlend, ColorBlendAttachmentState, ColorBlendState},
input_assembly::{InputAssemblyState, PrimitiveTopology}, input_assembly::{InputAssemblyState, PrimitiveTopology},
multisample::MultisampleState, multisample::MultisampleState,
@@ -26,15 +27,13 @@ use vulkano::{
subpass::PipelineRenderingCreateInfo, subpass::PipelineRenderingCreateInfo,
vertex_input::{Vertex, VertexDefinition, VertexInputState}, vertex_input::{Vertex, VertexDefinition, VertexInputState},
viewport::ViewportState, viewport::ViewportState,
GraphicsPipelineCreateInfo,
}, },
layout::PipelineDescriptorSetLayoutCreateInfo, layout::PipelineDescriptorSetLayoutCreateInfo,
DynamicState, GraphicsPipeline, Pipeline, PipelineLayout,
}, },
shader::{EntryPoint, ShaderModule}, shader::{EntryPoint, ShaderModule},
}; };
use super::{pass::WGfxPass, WGfx}; use super::{WGfx, pass::WGfxPass};
pub struct WGfxPipeline<V> { pub struct WGfxPipeline<V> {
pub graphics: Arc<WGfx>, pub graphics: Arc<WGfx>,

View File

@@ -1,9 +1,9 @@
use crate::{ use crate::{
components::{checkbox, radio_group::ComponentRadioGroup, Component}, components::{Component, checkbox, radio_group::ComponentRadioGroup},
i18n::Translation, i18n::Translation,
layout::WidgetID, layout::WidgetID,
parser::{ 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,
}, },
}; };

View File

@@ -1,7 +1,7 @@
use crate::{ use crate::{
components::{radio_group, Component}, components::{Component, radio_group},
layout::WidgetID, 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>( pub fn parse_component_radio_group<'a>(

View File

@@ -10,9 +10,24 @@ mod widget_rectangle;
mod widget_sprite; mod widget_sprite;
use crate::{ 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::{ assets::{AssetPath, AssetPathOwned, normalize_path},
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 components::{Component, ComponentWeak},
}, widget::ConstructEssentials 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 anyhow::Context;
use ouroboros::self_referencing; use ouroboros::self_referencing;
@@ -903,10 +918,20 @@ fn parse_child<'a>(
new_widget_id = Some(parse_component_slider(ctx, parent_id, &attribs)?); new_widget_id = Some(parse_component_slider(ctx, parent_id, &attribs)?);
} }
"CheckBox" => { "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" => { "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" => { "RadioGroup" => {
new_widget_id = Some(parse_component_radio_group(file, ctx, child_node, parent_id, &attribs)?); 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, allow_dtd: true,
..Default::default() ..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(); let root = document.borrow_doc().root();

View File

@@ -6,8 +6,8 @@ use taffy::{
use crate::{ use crate::{
drawing, drawing,
parser::{ parser::{
is_percent, parse_color_hex, parse_f32, parse_percent, parse_size_unit, parse_val, print_invalid_attrib, AttribPair, is_percent, parse_color_hex, parse_f32, parse_percent, parse_size_unit, parse_val,
print_invalid_value, AttribPair, print_invalid_attrib, print_invalid_value,
}, },
renderer_vk::text::{FontWeight, HorizontalAlign, TextStyle}, renderer_vk::text::{FontWeight, HorizontalAlign, TextStyle},
widget::util::WLength, widget::util::WLength,

View File

@@ -2,9 +2,8 @@ use crate::{
assets::AssetPath, assets::AssetPath,
layout::WidgetID, layout::WidgetID,
parser::{ 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}, style::{parse_color, parse_round, parse_style},
AttribPair, ParserContext, ParserFile,
}, },
renderer_vk::text::custom_glyph::CustomGlyphData, renderer_vk::text::custom_glyph::CustomGlyphData,
widget::image::{WidgetImage, WidgetImageParams}, widget::image::{WidgetImage, WidgetImageParams},

View File

@@ -2,9 +2,8 @@ use crate::{
drawing::GradientMode, drawing::GradientMode,
layout::WidgetID, layout::WidgetID,
parser::{ 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}, style::{parse_color, parse_round, parse_style},
AttribPair, ParserContext, ParserFile,
}, },
widget::rectangle::{WidgetRectangle, WidgetRectangleParams}, widget::rectangle::{WidgetRectangle, WidgetRectangleParams},
}; };

View File

@@ -1,7 +1,7 @@
use crate::{ use crate::{
assets::AssetPath, assets::AssetPath,
layout::WidgetID, 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, renderer_vk::text::custom_glyph::CustomGlyphData,
widget::sprite::{WidgetSprite, WidgetSpriteParams}, widget::sprite::{WidgetSprite, WidgetSpriteParams},
}; };

View File

@@ -14,10 +14,10 @@ use vulkano::{
use crate::{ use crate::{
drawing::{Boundary, ImagePrimitive}, drawing::{Boundary, ImagePrimitive},
gfx::{ gfx::{
BLEND_ALPHA, WGfx,
cmd::GfxCommandBuffer, cmd::GfxCommandBuffer,
pass::WGfxPass, pass::WGfxPass,
pipeline::{WGfxPipeline, WPipelineCreateInfo}, pipeline::{WGfxPipeline, WPipelineCreateInfo},
WGfx, BLEND_ALPHA,
}, },
renderer_vk::{ renderer_vk::{
model_buffer::ModelBuffer, model_buffer::ModelBuffer,

View File

@@ -10,10 +10,10 @@ use vulkano::{
use crate::{ use crate::{
drawing::{Boundary, Rectangle}, drawing::{Boundary, Rectangle},
gfx::{ gfx::{
BLEND_ALPHA, WGfx,
cmd::GfxCommandBuffer, cmd::GfxCommandBuffer,
pass::WGfxPass, pass::WGfxPass,
pipeline::{WGfxPipeline, WPipelineCreateInfo}, pipeline::{WGfxPipeline, WPipelineCreateInfo},
WGfx, BLEND_ALPHA,
}, },
renderer_vk::model_buffer::ModelBuffer, renderer_vk::model_buffer::ModelBuffer,
}; };

View File

@@ -3,8 +3,8 @@ use std::{
f32, f32,
hash::{DefaultHasher, Hasher}, hash::{DefaultHasher, Hasher},
sync::{ sync::{
atomic::{AtomicUsize, Ordering},
Arc, Weak, Arc, Weak,
atomic::{AtomicUsize, Ordering},
}, },
}; };

View File

@@ -4,9 +4,9 @@ use crate::{
}; };
use super::{ use super::{
ContentType, FontSystem, GlyphDetails, GpuCacheStatus, SwashCache, TextArea,
custom_glyph::{CustomGlyphCacheKey, RasterizeCustomGlyphRequest, RasterizedCustomGlyph}, custom_glyph::{CustomGlyphCacheKey, RasterizeCustomGlyphRequest, RasterizedCustomGlyph},
text_atlas::{GlyphVertex, TextAtlas, TextPipeline}, text_atlas::{GlyphVertex, TextAtlas, TextPipeline},
ContentType, FontSystem, GlyphDetails, GpuCacheStatus, SwashCache, TextArea,
}; };
use cosmic_text::{Color, SubpixelBin, SwashContent}; use cosmic_text::{Color, SubpixelBin, SwashContent};
use etagere::size2; use etagere::size2;

View File

@@ -698,7 +698,7 @@ fn get_format_params(fmt: Option<(&DrmFourcc, &Vec<DrmModifier>)>) -> Object {
} }
fn fourcc_to_spa(fourcc: DrmFourcc) -> VideoFormat { fn fourcc_to_spa(fourcc: DrmFourcc) -> VideoFormat {
match fourcc{ match fourcc {
DrmFourcc::Argb8888 => VideoFormat::BGRA, DrmFourcc::Argb8888 => VideoFormat::BGRA,
DrmFourcc::Abgr8888 => VideoFormat::RGBA, DrmFourcc::Abgr8888 => VideoFormat::RGBA,
DrmFourcc::Xrgb8888 => VideoFormat::BGRx, DrmFourcc::Xrgb8888 => VideoFormat::BGRx,

View File

@@ -3,8 +3,7 @@ use std::{path::PathBuf, sync::LazyLock};
const FALLBACK_CACHE_PATH: &str = "/tmp/wayvr_cache"; const FALLBACK_CACHE_PATH: &str = "/tmp/wayvr_cache";
static CACHE_ROOT_PATH: LazyLock<PathBuf> = LazyLock::new(|| { 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"); dir.push("wayvr");
return dir; return dir;
} }

View File

@@ -1,12 +1,19 @@
use std::{ 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, time::Instant,
}; };
use crate::cache_dir;
use ini::Ini; use ini::Ini;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use walkdir::WalkDir; use walkdir::WalkDir;
use crate::cache_dir;
struct DesktopEntryOwned { struct DesktopEntryOwned {
exec_path: String, exec_path: String,
@@ -50,8 +57,8 @@ struct DesktopFinderParams {
pub struct DesktopFinder { pub struct DesktopFinder {
params: Arc<DesktopFinderParams>, params: Arc<DesktopFinderParams>,
entry_cache: HashMap<String,DesktopEntry>, entry_cache: HashMap<String, DesktopEntry>,
bg_task: Option<JoinHandle<HashMap<String,DesktopEntryOwned>>>, bg_task: Option<JoinHandle<HashMap<String, DesktopEntryOwned>>>,
} }
impl DesktopFinder { impl DesktopFinder {
@@ -131,7 +138,10 @@ impl DesktopFinder {
} }
let file_name = entry.file_name().to_string_lossy(); 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; continue;
}; };
@@ -223,12 +233,15 @@ impl DesktopFinder {
known_files.insert(file_name.to_string()); known_files.insert(file_name.to_string());
entries.insert(app_id, DesktopEntryOwned { entries.insert(
app_id,
DesktopEntryOwned {
app_name: String::from(app_name), app_name: String::from(app_name),
exec_path: String::from(exec_path), exec_path: String::from(exec_path),
exec_args: exec_args.join(" "), exec_args: exec_args.join(" "),
icon_path, icon_path,
}); },
);
} }
} }