📦📎-fixes, typo fixes
This commit is contained in:
@@ -116,7 +116,7 @@ impl Frontend {
|
||||
};
|
||||
|
||||
// fixme: timer events instead of this thing
|
||||
if self.ticks % 1000 == 0 {
|
||||
if self.ticks.is_multiple_of(1000) {
|
||||
self.update_time(&mut common);
|
||||
}
|
||||
|
||||
|
||||
@@ -216,12 +216,12 @@ fn register_event_mouse_release<U1, U2>(
|
||||
if state.down {
|
||||
state.down = false;
|
||||
|
||||
if state.hovered {
|
||||
if let Some(on_click) = &state.on_click {
|
||||
if state.hovered
|
||||
&& let Some(on_click) = &state.on_click
|
||||
{
|
||||
on_click(common, ButtonClickEvent {})?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
common.alterables.trigger_haptics();
|
||||
common.alterables.mark_redraw();
|
||||
|
||||
@@ -229,12 +229,12 @@ fn register_event_mouse_release<U1, U2>(
|
||||
state.checked = !state.checked;
|
||||
set_box_checked(&common.state.widgets, &data, state.checked);
|
||||
|
||||
if state.hovered {
|
||||
if let Some(on_toggle) = &state.on_toggle {
|
||||
if state.hovered
|
||||
&& let Some(on_toggle) = &state.on_toggle
|
||||
{
|
||||
on_toggle(common, CheckboxToggleEvent { checked: state.checked })?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
common.alterables.trigger_haptics();
|
||||
common.alterables.mark_redraw();
|
||||
|
||||
@@ -129,7 +129,7 @@ pub struct CallbackDataCommon<'a> {
|
||||
}
|
||||
|
||||
impl CallbackDataCommon<'_> {
|
||||
pub fn i18n(&self) -> RefMut<I18n> {
|
||||
pub fn i18n(&self) -> RefMut<'_, I18n> {
|
||||
self.state.globals.i18n()
|
||||
}
|
||||
|
||||
|
||||
@@ -33,15 +33,15 @@ impl WguiGlobals {
|
||||
Ok(Self(Rc::new(RefCell::new(Globals { assets, i18n, defaults }))))
|
||||
}
|
||||
|
||||
pub fn get(&self) -> RefMut<Globals> {
|
||||
pub fn get(&self) -> RefMut<'_, Globals> {
|
||||
self.0.borrow_mut()
|
||||
}
|
||||
|
||||
pub fn i18n(&self) -> RefMut<I18n> {
|
||||
pub fn i18n(&self) -> RefMut<'_, I18n> {
|
||||
RefMut::map(self.0.borrow_mut(), |x| &mut x.i18n)
|
||||
}
|
||||
|
||||
pub fn assets(&self) -> RefMut<Box<dyn AssetProvider>> {
|
||||
pub fn assets(&self) -> RefMut<'_, Box<dyn AssetProvider>> {
|
||||
RefMut::map(self.0.borrow_mut(), |x| &mut x.assets)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,11 @@ impl Widget {
|
||||
Self(Rc::new(RefCell::new(widget_state)))
|
||||
}
|
||||
|
||||
pub fn get_as_mut<T: 'static>(&self) -> Option<RefMut<T>> {
|
||||
pub fn get_as_mut<T: 'static>(&self) -> Option<RefMut<'_, T>> {
|
||||
RefMut::filter_map(self.0.borrow_mut(), |w| w.obj.get_as_mut::<T>()).ok()
|
||||
}
|
||||
|
||||
pub fn state(&self) -> RefMut<WidgetState> {
|
||||
pub fn state(&self) -> RefMut<'_, WidgetState> {
|
||||
self.0.borrow_mut()
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ impl WidgetMap {
|
||||
Self(HopSlotMap::with_key())
|
||||
}
|
||||
|
||||
pub fn get_as<T: 'static>(&self, handle: WidgetID) -> Option<RefMut<T>> {
|
||||
pub fn get_as<T: 'static>(&self, handle: WidgetID) -> Option<RefMut<'_, T>> {
|
||||
self.0.get(handle)?.get_as_mut::<T>()
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
clippy::implicit_hasher,
|
||||
clippy::option_if_let_else,
|
||||
clippy::significant_drop_tightening,
|
||||
clippy::float_cmp
|
||||
clippy::float_cmp,
|
||||
clippy::needless_pass_by_ref_mut
|
||||
)]
|
||||
|
||||
pub mod animation;
|
||||
|
||||
@@ -208,8 +208,8 @@ pub fn parse_color_hex(html_hex: &str) -> Option<drawing::Color> {
|
||||
1.,
|
||||
));
|
||||
}
|
||||
} else if html_hex.len() == 9 {
|
||||
if let (Ok(r), Ok(g), Ok(b), Ok(a)) = (
|
||||
} else if html_hex.len() == 9
|
||||
&& let (Ok(r), Ok(g), Ok(b), Ok(a)) = (
|
||||
u8::from_str_radix(&html_hex[1..3], 16),
|
||||
u8::from_str_radix(&html_hex[3..5], 16),
|
||||
u8::from_str_radix(&html_hex[5..7], 16),
|
||||
@@ -222,7 +222,6 @@ pub fn parse_color_hex(html_hex: &str) -> Option<drawing::Color> {
|
||||
f32::from(a) / 255.,
|
||||
));
|
||||
}
|
||||
}
|
||||
log::warn!("failed to parse color \"{html_hex}\"");
|
||||
None
|
||||
}
|
||||
@@ -670,8 +669,9 @@ fn parse_child<'a, U1, U2>(
|
||||
}
|
||||
|
||||
// check for custom attributes (if the callback is set)
|
||||
if let Some(widget_id) = new_widget_id {
|
||||
if let Some(on_custom_attribs) = &ctx.doc_params.extra.on_custom_attribs {
|
||||
if let Some(widget_id) = new_widget_id
|
||||
&& let Some(on_custom_attribs) = &ctx.doc_params.extra.on_custom_attribs
|
||||
{
|
||||
let mut pairs = SmallVec::<[CustomAttribPair; 4]>::new();
|
||||
|
||||
for attrib in child_node.attributes() {
|
||||
@@ -697,7 +697,6 @@ fn parse_child<'a, U1, U2>(
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -752,7 +751,7 @@ impl CustomAttribsInfo<'_> {
|
||||
self.widgets.get(self.widget_id)
|
||||
}
|
||||
|
||||
pub fn get_widget_as<T: 'static>(&self) -> Option<RefMut<T>> {
|
||||
pub fn get_widget_as<T: 'static>(&self) -> Option<RefMut<'_, T>> {
|
||||
self.widgets.get(self.widget_id)?.get_as_mut::<T>()
|
||||
}
|
||||
|
||||
@@ -797,7 +796,7 @@ pub struct CustomAttribsInfoOwned {
|
||||
impl CustomAttribsInfoOwned {
|
||||
pub fn get_value(&self, attrib_name: &str) -> Option<&str> {
|
||||
// O(n) search, these pairs won't be problematically big anyways
|
||||
for pair in self.pairs.iter() {
|
||||
for pair in &self.pairs {
|
||||
if pair.attrib == attrib_name {
|
||||
return Some(pair.value.as_str());
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use crate::{
|
||||
globals::Globals,
|
||||
i18n::{I18n, Translation},
|
||||
layout::WidgetID,
|
||||
renderer_vk::text::{TextStyle, FONT_SYSTEM},
|
||||
renderer_vk::text::{FONT_SYSTEM, TextStyle},
|
||||
};
|
||||
|
||||
use super::{WidgetObj, WidgetState};
|
||||
@@ -86,7 +86,7 @@ impl WidgetLabel {
|
||||
|
||||
fn update_attrs(&mut self) {
|
||||
let attrs = Attrs::from(&self.params.style);
|
||||
for line in self.buffer.borrow_mut().lines.iter_mut() {
|
||||
for line in &mut self.buffer.borrow_mut().lines {
|
||||
line.set_attrs_list(AttrsList::new(&attrs));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,8 +331,10 @@ impl WidgetState {
|
||||
|
||||
match &event {
|
||||
Event::MouseDown(e) => {
|
||||
if hovered && self.data.set_device_pressed(e.device, true) {
|
||||
if let Some(listeners) = &listeners {
|
||||
if hovered
|
||||
&& self.data.set_device_pressed(e.device, true)
|
||||
&& let Some(listeners) = &listeners
|
||||
{
|
||||
call_event!(
|
||||
self,
|
||||
listeners,
|
||||
@@ -348,10 +350,10 @@ impl WidgetState {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::MouseUp(e) => {
|
||||
if self.data.set_device_pressed(e.device, false) {
|
||||
if let Some(listeners) = listeners {
|
||||
if self.data.set_device_pressed(e.device, false)
|
||||
&& let Some(listeners) = listeners
|
||||
{
|
||||
call_event!(
|
||||
self,
|
||||
listeners,
|
||||
@@ -367,7 +369,6 @@ impl WidgetState {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::MouseMotion(e) => {
|
||||
let hover_state_changed = self.data.set_device_hovered(e.device, hovered);
|
||||
|
||||
@@ -416,8 +417,9 @@ impl WidgetState {
|
||||
}
|
||||
}
|
||||
Event::MouseLeave(e) => {
|
||||
if self.data.set_device_hovered(e.device, false) {
|
||||
if let Some(listeners) = &listeners {
|
||||
if self.data.set_device_hovered(e.device, false)
|
||||
&& let Some(listeners) = &listeners
|
||||
{
|
||||
call_event!(
|
||||
self,
|
||||
listeners,
|
||||
@@ -430,7 +432,6 @@ impl WidgetState {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::InternalStateChange(e) => {
|
||||
if let Some(listeners) = &listeners {
|
||||
call_event!(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(clippy::expect_fun_call)]
|
||||
|
||||
use frame::{DrmFormat, WlxFrame};
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use std::any::Any;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicU32;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::mpsc;
|
||||
use std::sync::Arc;
|
||||
use std::thread::JoinHandle;
|
||||
|
||||
use ashpd::desktop::{
|
||||
screencast::{CursorMode, Screencast, SourceType},
|
||||
PersistMode,
|
||||
screencast::{CursorMode, Screencast, SourceType},
|
||||
};
|
||||
|
||||
pub use ashpd::Error as AshpdError;
|
||||
@@ -17,35 +17,35 @@ use pw::spa;
|
||||
|
||||
use pw::properties::properties;
|
||||
use pw::stream::{Stream, StreamFlags};
|
||||
use pw::{context::Context, main_loop::MainLoop, Error};
|
||||
use pw::{Error, context::Context, main_loop::MainLoop};
|
||||
use spa::buffer::DataType;
|
||||
use spa::buffer::MetaData;
|
||||
use spa::buffer::MetaType;
|
||||
use spa::param::ParamType;
|
||||
use spa::param::video::VideoFormat;
|
||||
use spa::param::video::VideoInfoRaw;
|
||||
use spa::param::ParamType;
|
||||
use spa::pod::serialize::GenError;
|
||||
use spa::pod::ChoiceValue;
|
||||
use spa::pod::Pod;
|
||||
use spa::pod::serialize::GenError;
|
||||
use spa::pod::{Object, Property, PropertyFlags, Value};
|
||||
use spa::utils::Choice;
|
||||
use spa::utils::ChoiceEnum;
|
||||
use spa::utils::ChoiceFlags;
|
||||
|
||||
use crate::WlxCapture;
|
||||
use crate::frame::DRM_FORMAT_ABGR8888;
|
||||
use crate::frame::DRM_FORMAT_ABGR2101010;
|
||||
use crate::frame::DRM_FORMAT_ARGB8888;
|
||||
use crate::frame::DRM_FORMAT_XBGR8888;
|
||||
use crate::frame::DRM_FORMAT_XBGR2101010;
|
||||
use crate::frame::DRM_FORMAT_XRGB8888;
|
||||
use crate::frame::DrmFormat;
|
||||
use crate::frame::FourCC;
|
||||
use crate::frame::FrameFormat;
|
||||
use crate::frame::MouseMeta;
|
||||
use crate::frame::Transform;
|
||||
use crate::frame::WlxFrame;
|
||||
use crate::frame::DRM_FORMAT_ABGR2101010;
|
||||
use crate::frame::DRM_FORMAT_ABGR8888;
|
||||
use crate::frame::DRM_FORMAT_ARGB8888;
|
||||
use crate::frame::DRM_FORMAT_XBGR2101010;
|
||||
use crate::frame::DRM_FORMAT_XBGR8888;
|
||||
use crate::frame::DRM_FORMAT_XRGB8888;
|
||||
use crate::frame::{DmabufFrame, FramePlane, MemFdFrame, MemPtrFrame};
|
||||
use crate::WlxCapture;
|
||||
|
||||
pub struct PipewireStream {
|
||||
pub node_id: u32,
|
||||
@@ -76,7 +76,7 @@ pub async fn pipewire_select_screen(
|
||||
|
||||
log::debug!("Available cursor modes: {cursor_modes:#x}");
|
||||
|
||||
// propery will be same system-wide, so race condition not a concern
|
||||
// properly will be same system-wide, so race condition not a concern
|
||||
CURSOR_MODES.store(cursor_modes, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
@@ -369,13 +369,12 @@ where
|
||||
}
|
||||
|
||||
if let Some(mut buffer) = maybe_buffer {
|
||||
if let MetaData::Header(header) = buffer.find_meta_data(MetaType::Header) {
|
||||
if header.flags & spa::sys::SPA_META_HEADER_FLAG_CORRUPTED != 0 {
|
||||
if let MetaData::Header(header) = buffer.find_meta_data(MetaType::Header)
|
||||
&& header.flags & spa::sys::SPA_META_HEADER_FLAG_CORRUPTED != 0
|
||||
{
|
||||
log::warn!("{}: PipeWire buffer is corrupt.", &name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if let MetaData::VideoTransform(transform) =
|
||||
buffer.find_meta_data(MetaType::VideoTransform)
|
||||
{
|
||||
|
||||
@@ -19,15 +19,15 @@ use smithay_client_toolkit::reexports::{
|
||||
|
||||
pub use wayland_client;
|
||||
use wayland_client::{
|
||||
Connection, Dispatch, EventQueue, Proxy, QueueHandle,
|
||||
backend::WaylandError,
|
||||
globals::{registry_queue_init, GlobalList, GlobalListContents},
|
||||
globals::{GlobalList, GlobalListContents, registry_queue_init},
|
||||
protocol::{
|
||||
wl_output::{self, Transform, WlOutput},
|
||||
wl_registry::{self, WlRegistry},
|
||||
wl_seat::WlSeat,
|
||||
wl_shm::WlShm,
|
||||
},
|
||||
Connection, Dispatch, EventQueue, Proxy, QueueHandle,
|
||||
};
|
||||
|
||||
use crate::frame;
|
||||
@@ -179,11 +179,11 @@ impl WlxClient {
|
||||
}
|
||||
},
|
||||
Err(err) => {
|
||||
if let WaylandError::Io(ref e) = err {
|
||||
if e.kind() == std::io::ErrorKind::WouldBlock {
|
||||
if let WaylandError::Io(ref e) = err
|
||||
&& e.kind() == std::io::ErrorKind::WouldBlock
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
log::warn!("Error while reading from event queue: {err:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ use smithay_client_toolkit::reexports::protocols_wlr::export_dmabuf::v1::client:
|
||||
use wayland_client::{Connection, QueueHandle, Dispatch, Proxy};
|
||||
|
||||
use crate::{
|
||||
WlxCapture,
|
||||
frame::{DmabufFrame, DrmFormat, FramePlane, WlxFrame},
|
||||
wayland::WlxClient,
|
||||
WlxCapture,
|
||||
};
|
||||
|
||||
use log::{debug, warn};
|
||||
@@ -84,8 +84,9 @@ where
|
||||
true
|
||||
}
|
||||
fn receive(&mut self) -> Option<R> {
|
||||
if let Some(data) = self.data.as_ref() {
|
||||
if let Some(WlxFrame::Dmabuf(last)) = data.receiver.try_iter().last() {
|
||||
if let Some(data) = self.data.as_ref()
|
||||
&& let Some(WlxFrame::Dmabuf(last)) = data.receiver.try_iter().last()
|
||||
{
|
||||
// this is the only protocol that requires us to manually close the FD
|
||||
while self.fds.len() > 6 * last.num_planes {
|
||||
// safe unwrap
|
||||
@@ -98,7 +99,6 @@ where
|
||||
}
|
||||
return (data.receive_callback)(&data.user_data, WlxFrame::Dmabuf(last));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
fn pause(&mut self) {}
|
||||
|
||||
@@ -3,16 +3,16 @@ use std::{
|
||||
env,
|
||||
error::Error,
|
||||
sync::{
|
||||
mpsc::{self},
|
||||
Arc,
|
||||
mpsc::{self},
|
||||
},
|
||||
};
|
||||
|
||||
use rxscreen::monitor::Monitor;
|
||||
|
||||
use crate::{
|
||||
frame::{DrmFormat, FrameFormat, MemPtrFrame, MouseMeta, WlxFrame, DRM_FORMAT_XRGB8888},
|
||||
WlxCapture,
|
||||
frame::{DRM_FORMAT_XRGB8888, DrmFormat, FrameFormat, MemPtrFrame, MouseMeta, WlxFrame},
|
||||
};
|
||||
|
||||
pub struct XshmScreen {
|
||||
@@ -169,10 +169,10 @@ where
|
||||
self.request_new_frame();
|
||||
}
|
||||
fn request_new_frame(&mut self) {
|
||||
if let Some(sender) = &self.sender {
|
||||
if let Err(e) = sender.send(()) {
|
||||
if let Some(sender) = &self.sender
|
||||
&& let Err(e) = sender.send(())
|
||||
{
|
||||
log::debug!("Failed to send frame request: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ use crate::{
|
||||
config::AStrSetExt,
|
||||
overlays::{
|
||||
anchor::create_anchor,
|
||||
keyboard::{builder::create_keyboard, KEYBOARD_NAME},
|
||||
keyboard::{KEYBOARD_NAME, builder::create_keyboard},
|
||||
screen::create_screens,
|
||||
watch::{create_watch, WATCH_NAME},
|
||||
watch::{WATCH_NAME, create_watch},
|
||||
},
|
||||
state::AppState,
|
||||
};
|
||||
@@ -57,11 +57,11 @@ where
|
||||
} else {
|
||||
match create_screens(app) {
|
||||
Ok((data, keymap)) => {
|
||||
if show_screens.is_empty() {
|
||||
if let Some((_, s, _)) = data.screens.first() {
|
||||
if show_screens.is_empty()
|
||||
&& let Some((_, s, _)) = data.screens.first()
|
||||
{
|
||||
show_screens.arc_set(s.name.clone());
|
||||
}
|
||||
}
|
||||
for (meta, mut state, backend) in data.screens {
|
||||
if show_screens.arc_get(state.name.as_ref()) {
|
||||
state.show_hide = true;
|
||||
|
||||
@@ -115,15 +115,15 @@ impl InputState {
|
||||
session.config.alt_click_up.iter()
|
||||
};
|
||||
|
||||
if let Some(program) = args.next() {
|
||||
if let Ok(child) = Command::new(program).args(args).spawn() {
|
||||
if let Some(program) = args.next()
|
||||
&& let Ok(child) = Command::new(program).args(args).spawn()
|
||||
{
|
||||
self.processes.push(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
fn debug_print_hand(hand: &Pointer) {
|
||||
@@ -283,13 +283,13 @@ pub enum PointerMode {
|
||||
}
|
||||
|
||||
fn update_focus(focus: &mut KeyboardFocus, state: &OverlayState) {
|
||||
if let Some(f) = &state.keyboard_focus {
|
||||
if *focus != *f {
|
||||
if let Some(f) = &state.keyboard_focus
|
||||
&& *focus != *f
|
||||
{
|
||||
log::info!("Setting keyboard focus to {:?}", *f);
|
||||
*focus = *f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn interact<O>(
|
||||
overlays: &mut OverlayContainer<O>,
|
||||
@@ -337,9 +337,11 @@ where
|
||||
pointer = &mut app.input_state.pointers[idx];
|
||||
pointer.interaction.hovered_id = None;
|
||||
}
|
||||
if !pointer.now.click && pointer.before.click {
|
||||
if let Some(clicked_id) = pointer.interaction.clicked_id.take() {
|
||||
if let Some(clicked) = overlays.mut_by_id(clicked_id) {
|
||||
if !pointer.now.click
|
||||
&& pointer.before.click
|
||||
&& let Some(clicked_id) = pointer.interaction.clicked_id.take()
|
||||
&& let Some(clicked) = overlays.mut_by_id(clicked_id)
|
||||
{
|
||||
let hit = PointerHit {
|
||||
pointer: pointer.idx,
|
||||
overlay: clicked_id,
|
||||
@@ -348,22 +350,19 @@ where
|
||||
};
|
||||
clicked.backend.on_pointer(app, &hit, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (0.0, None); // no hit
|
||||
};
|
||||
|
||||
if let Some(hovered_id) = pointer.interaction.hovered_id {
|
||||
if hovered_id != hit.overlay {
|
||||
if let Some(old_hovered) = overlays.mut_by_id(hovered_id) {
|
||||
if let Some(hovered_id) = pointer.interaction.hovered_id
|
||||
&& hovered_id != hit.overlay
|
||||
&& let Some(old_hovered) = overlays.mut_by_id(hovered_id)
|
||||
{
|
||||
if Some(pointer.idx) == old_hovered.primary_pointer {
|
||||
old_hovered.primary_pointer = None;
|
||||
}
|
||||
old_hovered.backend.on_left(app, idx);
|
||||
pointer = &mut app.input_state.pointers[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
let Some(hovered) = overlays.mut_by_id(hit.overlay) else {
|
||||
log::warn!("Hit overlay {} does not exist", hit.overlay.0);
|
||||
return (0.0, None); // no hit
|
||||
@@ -589,8 +588,9 @@ impl Pointer {
|
||||
pointer = &mut app.input_state.pointers[idx];
|
||||
|
||||
if save_success {
|
||||
if let Some(grab_data) = pointer.interaction.grabbed.as_ref() {
|
||||
if overlay.state.curvature != grab_data.old_curvature {
|
||||
if let Some(grab_data) = pointer.interaction.grabbed.as_ref()
|
||||
&& overlay.state.curvature != grab_data.old_curvature
|
||||
{
|
||||
if let Some(val) = overlay.state.curvature {
|
||||
app.session
|
||||
.config
|
||||
@@ -601,7 +601,6 @@ impl Pointer {
|
||||
app.session.config.curve_values.arc_rm(ref_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
app.session.config.transform_values.arc_set(
|
||||
overlay.state.name.clone(),
|
||||
overlay.state.saved_transform.unwrap(), // safe
|
||||
|
||||
@@ -21,8 +21,9 @@ pub(super) fn install_manifest(app_mgr: &mut ApplicationsManager) -> anyhow::Res
|
||||
.ok_or_else(|| anyhow::anyhow!("Invalid executable path"))?,
|
||||
};
|
||||
|
||||
if app_mgr.is_application_installed(APP_KEY) == Ok(true) {
|
||||
if let Ok(mut file) = File::open(&manifest_path) {
|
||||
if app_mgr.is_application_installed(APP_KEY) == Ok(true)
|
||||
&& let Ok(mut file) = File::open(&manifest_path)
|
||||
{
|
||||
let mut buf = String::new();
|
||||
if file.read_to_string(&mut buf).is_ok() {
|
||||
let manifest: json::JsonValue = json::parse(&buf)?;
|
||||
@@ -32,7 +33,6 @@ pub(super) fn install_manifest(app_mgr: &mut ApplicationsManager) -> anyhow::Res
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let manifest = object! {
|
||||
source: "builtin",
|
||||
|
||||
@@ -2,18 +2,18 @@ use std::{
|
||||
collections::VecDeque,
|
||||
ops::Add,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicUsize, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicBool, AtomicUsize, Ordering},
|
||||
},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use anyhow::{Result, anyhow};
|
||||
use ovr_overlay::{
|
||||
sys::{ETrackedDeviceProperty, EVRApplicationType, EVREventType},
|
||||
TrackedDeviceIndex,
|
||||
sys::{ETrackedDeviceProperty, EVRApplicationType, EVREventType},
|
||||
};
|
||||
use vulkano::{device::physical::PhysicalDevice, Handle, VulkanObject};
|
||||
use vulkano::{Handle, VulkanObject, device::physical::PhysicalDevice};
|
||||
|
||||
use crate::{
|
||||
backend::{
|
||||
@@ -21,7 +21,7 @@ use crate::{
|
||||
input::interact,
|
||||
openvr::{
|
||||
helpers::adjust_gain,
|
||||
input::{set_action_manifest, OpenVrInputSource},
|
||||
input::{OpenVrInputSource, set_action_manifest},
|
||||
lines::LinePool,
|
||||
manifest::{install_manifest, uninstall_manifest},
|
||||
overlay::OpenVrOverlayData,
|
||||
@@ -29,10 +29,10 @@ use crate::{
|
||||
overlay::{OverlayData, ShouldRender},
|
||||
task::{SystemTask, TaskType},
|
||||
},
|
||||
graphics::{init_openvr_graphics, CommandBuffers},
|
||||
graphics::{CommandBuffers, init_openvr_graphics},
|
||||
overlays::{
|
||||
toast::{Toast, ToastTopic},
|
||||
watch::{watch_fade, WATCH_NAME},
|
||||
watch::{WATCH_NAME, watch_fade},
|
||||
},
|
||||
state::AppState,
|
||||
subsystem::notifications::NotificationManager,
|
||||
@@ -229,13 +229,13 @@ pub fn openvr_run(
|
||||
});
|
||||
}
|
||||
TaskType::DropOverlay(sel) => {
|
||||
if let Some(o) = overlays.mut_by_selector(&sel) {
|
||||
if o.state.birthframe < cur_frame {
|
||||
if let Some(o) = overlays.mut_by_selector(&sel)
|
||||
&& o.state.birthframe < cur_frame
|
||||
{
|
||||
o.destroy(&mut overlay_mgr);
|
||||
overlays.remove_by_selector(&sel);
|
||||
}
|
||||
}
|
||||
}
|
||||
TaskType::System(task) => match task {
|
||||
SystemTask::ColorGain(channel, value) => {
|
||||
let _ = adjust_gain(&mut settings_mgr, channel, value);
|
||||
|
||||
@@ -61,13 +61,14 @@ fn set_clients_io_active(monado: &mut Monado, active: bool) {
|
||||
}
|
||||
};
|
||||
|
||||
if name != "wlx-overlay-s" && state.contains(ClientState::ClientSessionVisible) {
|
||||
if let Err(e) = client.set_io_active(active) {
|
||||
if name != "wlx-overlay-s"
|
||||
&& state.contains(ClientState::ClientSessionVisible)
|
||||
&& let Err(e) = client.set_io_active(active)
|
||||
{
|
||||
warn!("Failed to set io active for client: {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => warn!("Failed to get clients from Monado: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use glam::{bool, Affine3A, Quat, Vec3};
|
||||
use glam::{Affine3A, Quat, Vec3, bool};
|
||||
use libmonado as mnd;
|
||||
use openxr::{self as xr, Quaternionf, Vector2f, Vector3f};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -15,7 +15,7 @@ use crate::{
|
||||
state::{AppSession, AppState},
|
||||
};
|
||||
|
||||
use super::{helpers::posef_to_transform, XrState};
|
||||
use super::{XrState, helpers::posef_to_transform};
|
||||
|
||||
static CLICK_TIMES: [Duration; 3] = [
|
||||
Duration::ZERO,
|
||||
@@ -229,8 +229,9 @@ impl OpenXrInputSource {
|
||||
role: TrackedDeviceRole,
|
||||
app: &mut AppState,
|
||||
) {
|
||||
if let Ok(status) = device.battery_status() {
|
||||
if status.present {
|
||||
if let Ok(status) = device.battery_status()
|
||||
&& status.present
|
||||
{
|
||||
app.input_state.devices.push(TrackedDevice {
|
||||
soc: Some(status.charge),
|
||||
charging: status.charging,
|
||||
@@ -245,7 +246,6 @@ impl OpenXrInputSource {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_devices(app: &mut AppState, monado: &mut mnd::Monado) {
|
||||
app.input_state.devices.clear();
|
||||
@@ -268,13 +268,13 @@ impl OpenXrInputSource {
|
||||
let mut seen = Vec::<u32>::with_capacity(32);
|
||||
for (mnd_role, wlx_role) in roles {
|
||||
let device = monado.device_from_role(mnd_role);
|
||||
if let Ok(mut device) = device {
|
||||
if !seen.contains(&device.index) {
|
||||
if let Ok(mut device) = device
|
||||
&& !seen.contains(&device.index)
|
||||
{
|
||||
seen.push(device.index);
|
||||
Self::update_device_battery_status(&mut device, wlx_role, app);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Ok(devices) = monado.devices() {
|
||||
for mut device in devices {
|
||||
if !seen.contains(&device.index) {
|
||||
|
||||
@@ -2,8 +2,8 @@ use std::{
|
||||
collections::VecDeque,
|
||||
ops::Add,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicUsize, Ordering},
|
||||
Arc,
|
||||
atomic::{AtomicBool, AtomicUsize, Ordering},
|
||||
},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
@@ -23,10 +23,10 @@ use crate::{
|
||||
overlay::{OverlayData, ShouldRender},
|
||||
task::{SystemTask, TaskType},
|
||||
},
|
||||
graphics::{init_openxr_graphics, CommandBuffers},
|
||||
graphics::{CommandBuffers, init_openxr_graphics},
|
||||
overlays::{
|
||||
toast::{Toast, ToastTopic},
|
||||
watch::{watch_fade, WATCH_NAME},
|
||||
watch::{WATCH_NAME, watch_fade},
|
||||
},
|
||||
state::AppState,
|
||||
subsystem::notifications::NotificationManager,
|
||||
@@ -228,12 +228,12 @@ pub fn openxr_run(
|
||||
}
|
||||
}
|
||||
|
||||
if next_device_update <= Instant::now() {
|
||||
if let Some(monado) = &mut monado {
|
||||
if next_device_update <= Instant::now()
|
||||
&& let Some(monado) = &mut monado
|
||||
{
|
||||
OpenXrInputSource::update_devices(&mut app, monado);
|
||||
next_device_update = Instant::now() + Duration::from_secs(30);
|
||||
}
|
||||
}
|
||||
|
||||
if !session_running {
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
@@ -375,11 +375,9 @@ pub fn openxr_run(
|
||||
// Begin rendering
|
||||
let mut buffers = CommandBuffers::default();
|
||||
|
||||
if !main_session_visible {
|
||||
if let Some(skybox) = skybox.as_mut() {
|
||||
if !main_session_visible && let Some(skybox) = skybox.as_mut() {
|
||||
skybox.render(&xr_state, &app, &mut buffers)?;
|
||||
}
|
||||
}
|
||||
|
||||
for o in overlays.iter_mut() {
|
||||
o.data.cur_visible = false;
|
||||
@@ -427,13 +425,11 @@ pub fn openxr_run(
|
||||
|
||||
// Layer composition
|
||||
let mut layers = vec![];
|
||||
if !main_session_visible {
|
||||
if let Some(skybox) = skybox.as_mut() {
|
||||
if !main_session_visible && let Some(skybox) = skybox.as_mut() {
|
||||
for (idx, layer) in skybox.present(&xr_state, &app)?.into_iter().enumerate() {
|
||||
layers.push(((idx as f32).mul_add(-50.0, 200.0), layer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for o in overlays.iter_mut() {
|
||||
if !o.data.cur_visible {
|
||||
@@ -514,8 +510,9 @@ pub fn openxr_run(
|
||||
});
|
||||
}
|
||||
TaskType::DropOverlay(sel) => {
|
||||
if let Some(o) = overlays.mut_by_selector(&sel) {
|
||||
if o.state.birthframe < cur_frame {
|
||||
if let Some(o) = overlays.mut_by_selector(&sel)
|
||||
&& o.state.birthframe < cur_frame
|
||||
{
|
||||
log::debug!("{}: destroy", o.state.name);
|
||||
if let Some(o) = overlays.remove_by_selector(&sel) {
|
||||
// set for deletion after all images are done showing
|
||||
@@ -523,7 +520,6 @@ pub fn openxr_run(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TaskType::System(task) => match task {
|
||||
SystemTask::FixFloor => {
|
||||
if let Some(ref mut playspace) = playspace {
|
||||
|
||||
@@ -5,8 +5,8 @@ use openxr as xr;
|
||||
|
||||
use smallvec::SmallVec;
|
||||
use vulkano::{
|
||||
image::{sys::RawImage, view::ImageView, ImageCreateInfo, ImageUsage},
|
||||
Handle,
|
||||
image::{ImageCreateInfo, ImageUsage, sys::RawImage, view::ImageView},
|
||||
};
|
||||
use wgui::gfx::WGfx;
|
||||
|
||||
@@ -109,7 +109,7 @@ impl WlxSwapchain {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn get_subimage(&self) -> xr::SwapchainSubImage<xr::Vulkan> {
|
||||
pub(super) fn get_subimage(&self) -> xr::SwapchainSubImage<'_, xr::Vulkan> {
|
||||
debug_assert!(self.ever_acquired, "swapchain was never acquired!");
|
||||
xr::SwapchainSubImage::new()
|
||||
.swapchain(&self.swapchain)
|
||||
|
||||
@@ -247,18 +247,17 @@ where
|
||||
self.state.positioning,
|
||||
Positioning::Floating | Positioning::Anchored
|
||||
) {
|
||||
let hard_reset;
|
||||
if let Some(transform) = app
|
||||
let hard_reset = if let Some(transform) = app
|
||||
.session
|
||||
.config
|
||||
.transform_values
|
||||
.arc_get(self.state.name.as_ref())
|
||||
{
|
||||
self.state.saved_transform = Some(*transform);
|
||||
hard_reset = false;
|
||||
false
|
||||
} else {
|
||||
hard_reset = true;
|
||||
}
|
||||
true
|
||||
};
|
||||
self.state.reset(app, hard_reset);
|
||||
}
|
||||
self.backend.init(app)
|
||||
|
||||
@@ -10,8 +10,9 @@ use smithay::{
|
||||
use crate::backend::wayvr::{ExternalProcessRequest, WayVRTask};
|
||||
|
||||
use super::{
|
||||
ProcessWayVREnv,
|
||||
comp::{self, ClientState},
|
||||
display, process, ProcessWayVREnv,
|
||||
display, process,
|
||||
};
|
||||
|
||||
pub struct WayVRClient {
|
||||
@@ -118,8 +119,9 @@ impl WayVRCompositor {
|
||||
|
||||
// Find suitable auth key from the process list
|
||||
for p in processes.vec.iter().flatten() {
|
||||
if let process::Process::Managed(process) = &p.obj {
|
||||
if let Some(auth_key) = &process_env.display_auth {
|
||||
if let process::Process::Managed(process) = &p.obj
|
||||
&& let Some(auth_key) = &process_env.display_auth
|
||||
{
|
||||
// Find process with matching auth key
|
||||
if process.auth_key.as_str() == auth_key {
|
||||
// Check if display handle is valid
|
||||
@@ -135,7 +137,6 @@ impl WayVRCompositor {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is a new process which we didn't met before.
|
||||
// Treat external processes exclusively (spawned by the user or external program)
|
||||
@@ -160,11 +161,11 @@ impl WayVRCompositor {
|
||||
displays: &mut display::DisplayVec,
|
||||
processes: &mut process::ProcessVec,
|
||||
) -> anyhow::Result<()> {
|
||||
if let Some(stream) = self.listener.accept()? {
|
||||
if let Err(e) = self.accept_connection(stream, displays, processes) {
|
||||
if let Some(stream) = self.listener.accept()?
|
||||
&& let Err(e) = self.accept_connection(stream, displays, processes)
|
||||
{
|
||||
log::error!("Failed to accept connection: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||
|
||||
use smithay::{
|
||||
backend::renderer::{
|
||||
element::{
|
||||
surface::{render_elements_from_surface_tree, WaylandSurfaceRenderElement},
|
||||
Kind,
|
||||
},
|
||||
gles::{ffi, GlesRenderer, GlesTexture},
|
||||
utils::draw_render_elements,
|
||||
Bind, Color32F, Frame, Renderer,
|
||||
element::{
|
||||
Kind,
|
||||
surface::{WaylandSurfaceRenderElement, render_elements_from_surface_tree},
|
||||
},
|
||||
gles::{GlesRenderer, GlesTexture, ffi},
|
||||
utils::draw_render_elements,
|
||||
},
|
||||
input,
|
||||
utils::{Logical, Point, Rectangle, Size, Transform},
|
||||
@@ -22,8 +22,8 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
client::WayVRCompositor, comp::send_frames_surface_tree, egl_data, event_queue::SyncEventQueue,
|
||||
process, smithay_wrapper, time, window, BlitMethod, WayVRSignal,
|
||||
BlitMethod, WayVRSignal, client::WayVRCompositor, comp::send_frames_surface_tree, egl_data,
|
||||
event_queue::SyncEventQueue, process, smithay_wrapper, time, window,
|
||||
};
|
||||
|
||||
fn generate_auth_key() -> String {
|
||||
@@ -136,7 +136,9 @@ impl Display {
|
||||
BlitMethod::Dmabuf => match params.egl_data.create_dmabuf_data(&egl_image) {
|
||||
Ok(dmabuf_data) => egl_data::RenderData::Dmabuf(dmabuf_data),
|
||||
Err(e) => {
|
||||
log::error!("create_dmabuf_data failed: {e:?}. Using software blitting (This will be slow!)");
|
||||
log::error!(
|
||||
"create_dmabuf_data failed: {e:?}. Using software blitting (This will be slow!)"
|
||||
);
|
||||
egl_data::RenderData::Software(None)
|
||||
}
|
||||
},
|
||||
@@ -271,15 +273,14 @@ impl Display {
|
||||
if self.visible {
|
||||
if !self.displayed_windows.is_empty() {
|
||||
self.no_windows_since = None;
|
||||
} else if let Some(auto_hide_delay) = config.auto_hide_delay {
|
||||
if let Some(s) = self.no_windows_since {
|
||||
if s + u64::from(auto_hide_delay) < get_millis() {
|
||||
} else if let Some(auto_hide_delay) = config.auto_hide_delay
|
||||
&& let Some(s) = self.no_windows_since
|
||||
&& s + u64::from(auto_hide_delay) < get_millis()
|
||||
{
|
||||
// Auto-hide after specific time
|
||||
signals.send(WayVRSignal::DisplayVisibility(*handle, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while let Some(task) = self.tasks.read() {
|
||||
match task {
|
||||
|
||||
@@ -436,7 +436,7 @@ impl WayVR {
|
||||
.manager
|
||||
.tick_wayland(&mut self.state.displays, &mut self.state.processes)?;
|
||||
|
||||
if self.state.ticks % 200 == 0 {
|
||||
if self.state.ticks.is_multiple_of(200) {
|
||||
self.state.manager.cleanup_clients();
|
||||
}
|
||||
|
||||
@@ -460,12 +460,12 @@ impl WayVR {
|
||||
#[allow(dead_code)]
|
||||
pub fn get_primary_display(displays: &DisplayVec) -> Option<display::DisplayHandle> {
|
||||
for (idx, cell) in displays.vec.iter().enumerate() {
|
||||
if let Some(cell) = cell {
|
||||
if cell.obj.primary {
|
||||
if let Some(cell) = cell
|
||||
&& cell.obj.primary
|
||||
{
|
||||
return Some(DisplayVec::get_handle(cell, idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -474,12 +474,12 @@ impl WayVR {
|
||||
name: &str,
|
||||
) -> Option<display::DisplayHandle> {
|
||||
for (idx, cell) in displays.vec.iter().enumerate() {
|
||||
if let Some(cell) = cell {
|
||||
if cell.obj.name == name {
|
||||
if let Some(cell) = cell
|
||||
&& cell.obj.name == name
|
||||
{
|
||||
return Some(DisplayVec::get_handle(cell, idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -519,12 +519,12 @@ impl WayVRState {
|
||||
let changed = self.cur_modifiers ^ modifiers;
|
||||
for i in 0..8 {
|
||||
let m = 1 << i;
|
||||
if changed & m != 0 {
|
||||
if let Some(vk) = MODS_TO_KEYS.get(m).into_iter().flatten().next() {
|
||||
if changed & m != 0
|
||||
&& let Some(vk) = MODS_TO_KEYS.get(m).into_iter().flatten().next()
|
||||
{
|
||||
self.send_key(*vk as u32, modifiers & m != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.cur_modifiers = modifiers;
|
||||
}
|
||||
|
||||
@@ -652,8 +652,9 @@ impl WayVRState {
|
||||
_env: &[(&str, &str)],
|
||||
) -> Option<process::ProcessHandle> {
|
||||
for (idx, cell) in self.processes.vec.iter().enumerate() {
|
||||
if let Some(cell) = &cell {
|
||||
if let process::Process::Managed(process) = &cell.obj {
|
||||
if let Some(cell) = &cell
|
||||
&& let process::Process::Managed(process) = &cell.obj
|
||||
{
|
||||
if process.display_handle != display_handle
|
||||
|| process.exec_path != exec_path
|
||||
|| process.args != args
|
||||
@@ -663,7 +664,6 @@ impl WayVRState {
|
||||
return Some(process::ProcessVec::get_handle(cell, idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
@@ -97,12 +97,12 @@ fn get_process_env_value(pid: i32, key: &str) -> anyhow::Result<Option<String>>
|
||||
let lines: Vec<&str> = env_data.split('\0').filter(|s| !s.is_empty()).collect();
|
||||
|
||||
for line in lines {
|
||||
if let Some(cell) = line.split_once('=') {
|
||||
if cell.0 == key {
|
||||
if let Some(cell) = line.split_once('=')
|
||||
&& cell.0 == key
|
||||
{
|
||||
return Ok(Some(String::from(cell.1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
@@ -199,13 +199,13 @@ pub fn find_by_pid(processes: &ProcessVec, pid: u32) -> Option<ProcessHandle> {
|
||||
let Some(cell) = cell else {
|
||||
continue;
|
||||
};
|
||||
if let Process::Managed(wayvr_process) = &cell.obj {
|
||||
if wayvr_process.auth_key == value {
|
||||
if let Process::Managed(wayvr_process) = &cell.obj
|
||||
&& wayvr_process.auth_key == value
|
||||
{
|
||||
return Some(ProcessVec::get_handle(cell, idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log::debug!("Process find with PID {pid} failed");
|
||||
None
|
||||
|
||||
@@ -329,9 +329,7 @@ impl Connection {
|
||||
handle: packet_server::WvrWindowHandle,
|
||||
visible: bool,
|
||||
) {
|
||||
let mut to_resize = None;
|
||||
|
||||
if let Some(window) = params
|
||||
let to_resize = if let Some(window) = params
|
||||
.state
|
||||
.wm
|
||||
.borrow_mut()
|
||||
@@ -339,16 +337,18 @@ impl Connection {
|
||||
.get_mut(&window::WindowHandle::from_packet(handle))
|
||||
{
|
||||
window.visible = visible;
|
||||
to_resize = Some(window.display_handle);
|
||||
}
|
||||
Some(window.display_handle)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if let Some(to_resize) = to_resize {
|
||||
if let Some(display) = params.state.displays.get_mut(&to_resize) {
|
||||
if let Some(to_resize) = to_resize
|
||||
&& let Some(display) = params.state.displays.get_mut(&to_resize)
|
||||
{
|
||||
display.reposition_windows();
|
||||
display.trigger_rerender();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_wvr_process_launch(
|
||||
&mut self,
|
||||
|
||||
@@ -18,7 +18,7 @@ use crate::{
|
||||
},
|
||||
config::load_config_with_conf_d,
|
||||
config_io,
|
||||
overlays::wayvr::{executable_exists_in_path, WayVRData},
|
||||
overlays::wayvr::{WayVRData, executable_exists_in_path},
|
||||
};
|
||||
|
||||
// Flat version of RelativeTo
|
||||
@@ -211,8 +211,9 @@ impl WayVRConfig {
|
||||
|
||||
for (catalog_name, catalog) in &self.catalogs {
|
||||
for app in &catalog.apps {
|
||||
if let Some(b) = app.shown_at_start {
|
||||
if b {
|
||||
if let Some(b) = app.shown_at_start
|
||||
&& b
|
||||
{
|
||||
tasks.enqueue(TaskType::WayVR(WayVRAction::AppClick {
|
||||
catalog_name: Arc::from(catalog_name.as_str()),
|
||||
app_name: Arc::from(app.name.as_str()),
|
||||
@@ -220,7 +221,6 @@ impl WayVRConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if self.run_compositor_at_start {
|
||||
// Start Wayland server instantly
|
||||
|
||||
@@ -11,7 +11,7 @@ use wgui::{
|
||||
|
||||
use crate::{
|
||||
backend::{common::OverlaySelector, overlay::OverlayID, task::TaskType, wayvr::WayVRAction},
|
||||
config::{save_layout, AStrSetExt},
|
||||
config::{AStrSetExt, save_layout},
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
@@ -21,14 +21,14 @@ pub(super) fn setup_custom_button<S>(
|
||||
attribs: &CustomAttribsInfoOwned,
|
||||
listeners: &mut EventListenerCollection<AppState, S>,
|
||||
listener_handles: &mut ListenerHandleVec,
|
||||
app: &AppState,
|
||||
_app: &AppState,
|
||||
) {
|
||||
const EVENTS: [(&str, EventListenerKind); 2] = [
|
||||
("press", EventListenerKind::MousePress),
|
||||
("release", EventListenerKind::MouseRelease),
|
||||
];
|
||||
|
||||
for (name, kind) in EVENTS.iter() {
|
||||
for (name, kind) in &EVENTS {
|
||||
let Some(action) = attribs.get_value(name) else {
|
||||
continue;
|
||||
};
|
||||
@@ -47,14 +47,14 @@ pub(super) fn setup_custom_button<S>(
|
||||
}),
|
||||
"::OverlayToggle" => {
|
||||
let Some(selector) = args.next() else {
|
||||
log::warn!("Missing argument for {}", command);
|
||||
log::warn!("Missing argument for {command}");
|
||||
continue;
|
||||
};
|
||||
|
||||
let selector = selector
|
||||
.parse::<usize>()
|
||||
.map(|id| OverlaySelector::Id(OverlayID { 0: id }))
|
||||
.unwrap_or_else(|_| OverlaySelector::Name(selector.into()));
|
||||
let selector = selector.parse::<usize>().map_or_else(
|
||||
|_| OverlaySelector::Name(selector.into()),
|
||||
|id| OverlaySelector::Id(OverlayID(id)),
|
||||
);
|
||||
|
||||
Box::new(move |_common, _data, app, _| {
|
||||
app.tasks.enqueue(TaskType::Overlay(
|
||||
@@ -90,7 +90,11 @@ pub(super) fn setup_custom_button<S>(
|
||||
}
|
||||
"::WatchHide" => todo!(),
|
||||
"::WatchSwapHand" => todo!(),
|
||||
// TODO
|
||||
#[allow(clippy::match_same_arms)]
|
||||
"::EditToggle" => return,
|
||||
// TODO
|
||||
#[allow(clippy::match_same_arms)]
|
||||
"::OscSend" => return,
|
||||
// shell
|
||||
_ => todo!(),
|
||||
@@ -110,18 +114,20 @@ struct ShellButtonState {
|
||||
carry_over: RefCell<Option<String>>,
|
||||
}
|
||||
|
||||
// TODO
|
||||
#[allow(clippy::missing_const_for_fn)]
|
||||
fn shell_on_action(
|
||||
state: &ShellButtonState,
|
||||
common: &mut event::CallbackDataCommon,
|
||||
data: &mut event::CallbackData,
|
||||
_state: &ShellButtonState,
|
||||
_common: &mut event::CallbackDataCommon,
|
||||
_data: &mut event::CallbackData,
|
||||
) {
|
||||
let mut mut_state = state.mut_state.borrow_mut();
|
||||
//let mut mut_state = state.mut_state.borrow_mut();
|
||||
}
|
||||
|
||||
fn shell_on_tick(
|
||||
state: &ShellButtonState,
|
||||
common: &mut event::CallbackDataCommon,
|
||||
data: &mut event::CallbackData,
|
||||
_common: &mut event::CallbackDataCommon,
|
||||
_data: &mut event::CallbackData,
|
||||
) {
|
||||
let mut mut_state = state.mut_state.borrow_mut();
|
||||
|
||||
@@ -129,8 +135,8 @@ fn shell_on_tick(
|
||||
match child.try_wait() {
|
||||
// not exited yet
|
||||
Ok(None) => {
|
||||
if let Some(text) = mut_state.reader.as_mut().and_then(|r| {
|
||||
read_label_from_pipe("child process", r, &mut *state.carry_over.borrow_mut())
|
||||
if let Some(_text) = mut_state.reader.as_mut().and_then(|r| {
|
||||
read_label_from_pipe("child process", r, &mut state.carry_over.borrow_mut())
|
||||
}) {
|
||||
//TODO update label
|
||||
}
|
||||
@@ -138,8 +144,8 @@ fn shell_on_tick(
|
||||
}
|
||||
// exited successfully
|
||||
Ok(Some(code)) if code.success() => {
|
||||
if let Some(text) = mut_state.reader.as_mut().and_then(|r| {
|
||||
read_label_from_pipe("child process", r, &mut *state.carry_over.borrow_mut())
|
||||
if let Some(_text) = mut_state.reader.as_mut().and_then(|r| {
|
||||
read_label_from_pipe("child process", r, &mut state.carry_over.borrow_mut())
|
||||
}) {
|
||||
//TODO update label
|
||||
}
|
||||
@@ -148,7 +154,7 @@ fn shell_on_tick(
|
||||
// exited with failure
|
||||
Ok(Some(code)) => {
|
||||
mut_state.child = None;
|
||||
log::warn!("Label process exited with code {}", code);
|
||||
log::warn!("Label process exited with code {code}");
|
||||
}
|
||||
// lost
|
||||
Err(_) => {
|
||||
|
||||
@@ -11,7 +11,7 @@ static ENV_VAR_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
||||
pub(super) fn expand_env_vars(template: &str) -> String {
|
||||
ENV_VAR_REGEX
|
||||
.replace_all(template, |caps: ®ex::Captures| {
|
||||
let var_name = caps.get(1).or(caps.get(2)).unwrap().as_str();
|
||||
let var_name = caps.get(1).or_else(|| caps.get(2)).unwrap().as_str();
|
||||
std::env::var(var_name)
|
||||
.inspect_err(|e| log::warn!("Unable to substitute env var {var_name}: {e:?}"))
|
||||
.unwrap_or_default()
|
||||
@@ -45,9 +45,5 @@ where
|
||||
|
||||
carry_over.replace(cur);
|
||||
|
||||
if prev.len() > 0 {
|
||||
Some(prev)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
if prev.is_empty() { None } else { Some(prev) }
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ use wgui::{
|
||||
event::{self, EventCallback, EventListenerCollection, ListenerHandleVec},
|
||||
i18n::Translation,
|
||||
layout::Layout,
|
||||
parser::{parse_color_hex, CustomAttribsInfoOwned},
|
||||
parser::{CustomAttribsInfoOwned, parse_color_hex},
|
||||
widget::label::WidgetLabel,
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@ use crate::state::AppState;
|
||||
|
||||
use super::helper::{expand_env_vars, read_label_from_pipe};
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub(super) fn setup_custom_label<S>(
|
||||
layout: &mut Layout,
|
||||
attribs: &CustomAttribsInfoOwned,
|
||||
@@ -85,15 +86,15 @@ pub(super) fn setup_custom_label<S>(
|
||||
let state = BatteryLabelState {
|
||||
low_color: attribs
|
||||
.get_value("low_color")
|
||||
.and_then(|s| parse_color_hex(s))
|
||||
.and_then(parse_color_hex)
|
||||
.unwrap_or(BAT_LOW),
|
||||
normal_color: attribs
|
||||
.get_value("normal_color")
|
||||
.and_then(|s| parse_color_hex(s))
|
||||
.and_then(parse_color_hex)
|
||||
.unwrap_or(BAT_NORMAL),
|
||||
charging_color: attribs
|
||||
.get_value("charging_color")
|
||||
.and_then(|s| parse_color_hex(s))
|
||||
.and_then(parse_color_hex)
|
||||
.unwrap_or(BAT_CHARGING),
|
||||
low_threshold: attribs
|
||||
.get_value("low_threshold")
|
||||
@@ -122,10 +123,7 @@ pub(super) fn setup_custom_label<S>(
|
||||
tz_name.split('/').next_back().map(|x| x.replace('_', " "))
|
||||
});
|
||||
|
||||
let pretty_tz = match maybe_pretty_tz.as_ref() {
|
||||
Some(x) => x.as_str(),
|
||||
None => "Local",
|
||||
};
|
||||
let pretty_tz = maybe_pretty_tz.as_ref().map_or("Local", |x| x.as_str());
|
||||
|
||||
let mut i18n = layout.state.globals.i18n();
|
||||
layout
|
||||
@@ -133,7 +131,7 @@ pub(super) fn setup_custom_label<S>(
|
||||
.widgets
|
||||
.get_as::<WidgetLabel>(attribs.widget_id)
|
||||
.unwrap()
|
||||
.set_text_simple(&mut *i18n, Translation::from_raw_text(&pretty_tz));
|
||||
.set_text_simple(&mut i18n, Translation::from_raw_text(pretty_tz));
|
||||
|
||||
// does not need to be dynamic
|
||||
return;
|
||||
@@ -202,6 +200,7 @@ struct ShellLabelState {
|
||||
carry_over: RefCell<Option<String>>,
|
||||
}
|
||||
|
||||
#[allow(clippy::redundant_else)]
|
||||
fn shell_on_tick(
|
||||
state: &ShellLabelState,
|
||||
common: &mut event::CallbackDataCommon,
|
||||
@@ -214,7 +213,7 @@ fn shell_on_tick(
|
||||
// not exited yet
|
||||
Ok(None) => {
|
||||
if let Some(text) = mut_state.reader.as_mut().and_then(|r| {
|
||||
read_label_from_pipe("child process", r, &mut *state.carry_over.borrow_mut())
|
||||
read_label_from_pipe("child process", r, &mut state.carry_over.borrow_mut())
|
||||
}) {
|
||||
let label = data.obj.get_as_mut::<WidgetLabel>().unwrap();
|
||||
label.set_text(common, Translation::from_raw_text(&text));
|
||||
@@ -225,7 +224,7 @@ fn shell_on_tick(
|
||||
// exited successfully
|
||||
Ok(Some(code)) if code.success() => {
|
||||
if let Some(text) = mut_state.reader.as_mut().and_then(|r| {
|
||||
read_label_from_pipe("child process", r, &mut *state.carry_over.borrow_mut())
|
||||
read_label_from_pipe("child process", r, &mut state.carry_over.borrow_mut())
|
||||
}) {
|
||||
let label = data.obj.get_as_mut::<WidgetLabel>().unwrap();
|
||||
label.set_text(common, Translation::from_raw_text(&text));
|
||||
@@ -237,7 +236,7 @@ fn shell_on_tick(
|
||||
Ok(Some(code)) => {
|
||||
mut_state.child = None;
|
||||
mut_state.next_try = Instant::now() + Duration::from_secs(15);
|
||||
log::warn!("Label process exited with code {}", code);
|
||||
log::warn!("Label process exited with code {code}");
|
||||
return;
|
||||
}
|
||||
// lost
|
||||
@@ -248,11 +247,9 @@ fn shell_on_tick(
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if mut_state.next_try > Instant::now() {
|
||||
} else if mut_state.next_try > Instant::now() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
match Command::new("sh")
|
||||
.arg("-c")
|
||||
@@ -266,7 +263,7 @@ fn shell_on_tick(
|
||||
mut_state.reader = Some(io::BufReader::new(stdout));
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Failed to run shell script '{}': {e:?}", &state.exec)
|
||||
log::warn!("Failed to run shell script '{}': {e:?}", &state.exec);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,7 +297,7 @@ impl FifoLabelState {
|
||||
|
||||
if let Err(e) = fs::remove_file(&self.path) {
|
||||
anyhow::bail!("Unable to remove existing FIFO at {}: {e:?}", &self.path);
|
||||
};
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -321,9 +318,9 @@ fn pipe_on_tick(
|
||||
) {
|
||||
let mut mut_state = state.mut_state.borrow_mut();
|
||||
|
||||
let reader = match mut_state.reader.as_mut() {
|
||||
Some(f) => f,
|
||||
None => {
|
||||
let reader = if let Some(f) = mut_state.reader.as_mut() {
|
||||
f
|
||||
} else {
|
||||
if mut_state.next_try > Instant::now() {
|
||||
return;
|
||||
}
|
||||
@@ -345,15 +342,14 @@ fn pipe_on_tick(
|
||||
log::warn!("Failed to open FIFO: {e:?}");
|
||||
mut_state.next_try = Instant::now() + Duration::from_secs(15);
|
||||
})
|
||||
.map(|f| io::BufReader::new(f))
|
||||
.map(io::BufReader::new)
|
||||
.ok();
|
||||
|
||||
mut_state.reader.as_mut().unwrap()
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(text) =
|
||||
read_label_from_pipe(&state.path, reader, &mut *state.carry_over.borrow_mut())
|
||||
read_label_from_pipe(&state.path, reader, &mut state.carry_over.borrow_mut())
|
||||
{
|
||||
let label = data.obj.get_as_mut::<WidgetLabel>().unwrap();
|
||||
label.set_text(common, Translation::from_raw_text(&text));
|
||||
@@ -385,8 +381,9 @@ fn battery_on_tick(
|
||||
|
||||
let label = data.obj.get_as_mut::<WidgetLabel>().unwrap();
|
||||
|
||||
if let Some(device) = device {
|
||||
if let Some(soc) = device.soc {
|
||||
if let Some(device) = device
|
||||
&& let Some(soc) = device.soc
|
||||
{
|
||||
let soc = (soc * 100.).min(99.) as u32;
|
||||
let text = format!("{}{}", tags[device.role as usize], soc);
|
||||
let color = if device.charging {
|
||||
@@ -400,7 +397,6 @@ fn battery_on_tick(
|
||||
label.set_text(common, Translation::from_raw_text(&text));
|
||||
return;
|
||||
}
|
||||
}
|
||||
label.set_text(common, Translation::default());
|
||||
}
|
||||
|
||||
|
||||
@@ -269,8 +269,9 @@ fn ensure_single_instance(replace: bool) -> bool {
|
||||
|
||||
if path.exists() {
|
||||
// load contents
|
||||
if let Ok(pid_str) = std::fs::read_to_string(&path) {
|
||||
if let Ok(pid) = pid_str.trim().parse::<u32>() {
|
||||
if let Ok(pid_str) = std::fs::read_to_string(&path)
|
||||
&& let Ok(pid) = pid_str.trim().parse::<u32>()
|
||||
{
|
||||
let mut system = sysinfo::System::new();
|
||||
system.refresh_processes(
|
||||
sysinfo::ProcessesToUpdate::Some(&[Pid::from_u32(pid)]),
|
||||
@@ -286,7 +287,6 @@ fn ensure_single_instance(replace: bool) -> bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let pid = std::process::id().to_string();
|
||||
std::fs::write(path, pid).unwrap();
|
||||
|
||||
@@ -204,11 +204,11 @@ fn handle_release(app: &mut AppState, key: &KeyState, keyboard: &mut KeyboardSta
|
||||
.processes
|
||||
.retain_mut(|child| !matches!(child.try_wait(), Ok(Some(_))));
|
||||
|
||||
if let Some(program) = release_program {
|
||||
if let Ok(child) = Command::new(program).args(release_args).spawn() {
|
||||
if let Some(program) = release_program
|
||||
&& let Ok(child) = Command::new(program).args(release_args).spawn()
|
||||
{
|
||||
keyboard.processes.push(child);
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
_ => true,
|
||||
|
||||
@@ -83,11 +83,11 @@ pub(super) fn select_pw_screen(
|
||||
task::Poll::Pending => {
|
||||
if Instant::now() >= print_at {
|
||||
log::info!("{instructions}");
|
||||
if let Ok(sender) = DbusNotificationSender::new() {
|
||||
if let Ok(id) = sender.notify_send(instructions, "", 2, 0, 0, true) {
|
||||
if let Ok(sender) = DbusNotificationSender::new()
|
||||
&& let Ok(id) = sender.notify_send(instructions, "", 2, 0, 0, true)
|
||||
{
|
||||
notify = Some((sender, id));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
futures::future::lazy(|_| {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use glam::vec2;
|
||||
use wlx_capture::{
|
||||
WlxCapture,
|
||||
wayland::{WlxClient, WlxOutput},
|
||||
wlr_dmabuf::WlrDmabufCapture,
|
||||
wlr_screencopy::WlrScreencopyCapture,
|
||||
WlxCapture,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -13,10 +13,10 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
backend::ScreenBackend,
|
||||
capture::{new_wlx_capture, MainThreadWlxCapture},
|
||||
pw::{load_pw_token_config, save_pw_token_config},
|
||||
ScreenCreateData,
|
||||
backend::ScreenBackend,
|
||||
capture::{MainThreadWlxCapture, new_wlx_capture},
|
||||
pw::{load_pw_token_config, save_pw_token_config},
|
||||
};
|
||||
|
||||
impl ScreenBackend {
|
||||
@@ -76,12 +76,12 @@ pub fn create_screen_renderer_wl(
|
||||
Ok((renderer, restore_token)) => {
|
||||
capture = Some(renderer);
|
||||
|
||||
if let Some(token) = restore_token {
|
||||
if pw_token_store.arc_set(display_name.into(), token.clone()) {
|
||||
if let Some(token) = restore_token
|
||||
&& pw_token_store.arc_set(display_name.into(), token.clone())
|
||||
{
|
||||
log::info!("Adding Pipewire token {token}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!(
|
||||
"{}: Failed to create Pipewire capture: {:?}",
|
||||
|
||||
@@ -2,9 +2,9 @@ use std::sync::Arc;
|
||||
|
||||
use glam::vec2;
|
||||
use wlx_capture::{
|
||||
WlxCapture,
|
||||
frame::Transform,
|
||||
xshm::{XshmCapture, XshmScreen},
|
||||
WlxCapture,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -13,9 +13,9 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
backend::ScreenBackend,
|
||||
capture::{new_wlx_capture, MainThreadWlxCapture},
|
||||
ScreenCreateData,
|
||||
backend::ScreenBackend,
|
||||
capture::{MainThreadWlxCapture, new_wlx_capture},
|
||||
};
|
||||
|
||||
#[cfg(feature = "pipewire")]
|
||||
@@ -62,11 +62,11 @@ pub fn create_screens_x11pw(app: &mut AppState) -> anyhow::Result<ScreenCreateDa
|
||||
true,
|
||||
)?;
|
||||
|
||||
if let Some(restore_token) = select_screen_result.restore_token {
|
||||
if pw_tokens.arc_set("x11".into(), restore_token.clone()) {
|
||||
if let Some(restore_token) = select_screen_result.restore_token
|
||||
&& pw_tokens.arc_set("x11".into(), restore_token.clone())
|
||||
{
|
||||
log::info!("Adding Pipewire token {restore_token}");
|
||||
}
|
||||
}
|
||||
if pw_tokens_copy != pw_tokens {
|
||||
// Token list changed, re-create token config file
|
||||
if let Err(err) = save_pw_token_config(pw_tokens) {
|
||||
|
||||
@@ -809,11 +809,11 @@ where
|
||||
O: Default,
|
||||
{
|
||||
if let Some(display) = WayVR::get_display_by_name(&wayvr.data.state.displays, display_name) {
|
||||
if let Some(overlay_id) = wayvr.display_handle_map.get(&display) {
|
||||
if let Some(overlay) = overlays.mut_by_id(*overlay_id) {
|
||||
if let Some(overlay_id) = wayvr.display_handle_map.get(&display)
|
||||
&& let Some(overlay) = overlays.mut_by_id(*overlay_id)
|
||||
{
|
||||
overlay.state.want_visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
wayvr.data.state.set_display_visible(display, true);
|
||||
}
|
||||
|
||||
@@ -218,12 +218,12 @@ impl HidProvider for UInputProvider {
|
||||
let changed = self.cur_modifiers ^ modifiers;
|
||||
for i in 0..8 {
|
||||
let m = 1 << i;
|
||||
if changed & m != 0 {
|
||||
if let Some(vk) = MODS_TO_KEYS.get(m).into_iter().flatten().next() {
|
||||
if changed & m != 0
|
||||
&& let Some(vk) = MODS_TO_KEYS.get(m).into_iter().flatten().next()
|
||||
{
|
||||
self.send_key(*vk, modifiers & m != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
self.cur_modifiers = modifiers;
|
||||
}
|
||||
fn send_key(&self, key: VirtualKey, down: bool) {
|
||||
@@ -564,14 +564,14 @@ pub struct XkbKeymap {
|
||||
impl XkbKeymap {
|
||||
pub fn label_for_key(&self, key: VirtualKey, modifier: KeyModifier) -> String {
|
||||
let mut state = xkb::State::new(&self.keymap);
|
||||
if modifier > 0 {
|
||||
if let Some(mod_key) = MODS_TO_KEYS.get(modifier) {
|
||||
if modifier > 0
|
||||
&& let Some(mod_key) = MODS_TO_KEYS.get(modifier)
|
||||
{
|
||||
state.update_key(
|
||||
xkb::Keycode::from(mod_key[0] as u32),
|
||||
xkb::KeyDirection::Down,
|
||||
);
|
||||
}
|
||||
}
|
||||
state.key_get_utf8(xkb::Keycode::from(key as u32))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use wlx_capture::wayland::wayland_client::{
|
||||
globals::{registry_queue_init, GlobalListContents},
|
||||
Connection, Dispatch, Proxy, QueueHandle,
|
||||
globals::{GlobalListContents, registry_queue_init},
|
||||
protocol::{
|
||||
wl_keyboard::{self, WlKeyboard},
|
||||
wl_registry::WlRegistry,
|
||||
wl_seat::{self, Capability, WlSeat},
|
||||
},
|
||||
Connection, Dispatch, Proxy, QueueHandle,
|
||||
};
|
||||
use xkbcommon::xkb;
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn get_keymap_wl() -> anyhow::Result<XkbKeymap> {
|
||||
let qh = queue.handle();
|
||||
let seat: WlSeat = globals
|
||||
.bind(&qh, 4..=9, ())
|
||||
.expect(WlSeat::interface().name);
|
||||
.unwrap_or_else(|_| panic!("{}", WlSeat::interface().name));
|
||||
|
||||
let mut me = WlKeymapHandler {
|
||||
seat,
|
||||
|
||||
Reference in New Issue
Block a user