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