clippy
This commit is contained in:
@@ -375,8 +375,8 @@ where
|
|||||||
// focus change
|
// focus change
|
||||||
if let Some(hovered_id) = hovered_id
|
if let Some(hovered_id) = hovered_id
|
||||||
&& hovered_id != hit.overlay
|
&& hovered_id != hit.overlay
|
||||||
|
&& let Some(old_hovered) = overlays.mut_by_id(hovered_id)
|
||||||
{
|
{
|
||||||
if let Some(old_hovered) = overlays.mut_by_id(hovered_id) {
|
|
||||||
if old_hovered.primary_pointer.is_some_and(|i| i == idx) {
|
if old_hovered.primary_pointer.is_some_and(|i| i == idx) {
|
||||||
old_hovered.primary_pointer = None;
|
old_hovered.primary_pointer = None;
|
||||||
}
|
}
|
||||||
@@ -387,7 +387,6 @@ where
|
|||||||
overlays.edit_overlay(hovered_id, false, app);
|
overlays.edit_overlay(hovered_id, false, app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
overlays.edit_overlay(hit.overlay, true, app);
|
overlays.edit_overlay(hit.overlay, true, app);
|
||||||
let edit_mode = overlays.get_edit_mode();
|
let edit_mode = overlays.get_edit_mode();
|
||||||
@@ -472,8 +471,9 @@ fn handle_no_hit<O>(
|
|||||||
overlays: &mut OverlayWindowManager<O>,
|
overlays: &mut OverlayWindowManager<O>,
|
||||||
app: &mut AppState,
|
app: &mut AppState,
|
||||||
) {
|
) {
|
||||||
if let Some(hovered_id) = hovered_id {
|
if let Some(hovered_id) = hovered_id
|
||||||
if let Some(hovered) = overlays.mut_by_id(hovered_id) {
|
&& let Some(hovered) = overlays.mut_by_id(hovered_id)
|
||||||
|
{
|
||||||
log::debug!("{} on_left (no hit)", hovered.config.name);
|
log::debug!("{} on_left (no hit)", hovered.config.name);
|
||||||
hovered.config.backend.on_left(app, pointer_idx);
|
hovered.config.backend.on_left(app, pointer_idx);
|
||||||
hovered.hover_pointers[pointer_idx] = false;
|
hovered.hover_pointers[pointer_idx] = false;
|
||||||
@@ -481,7 +481,6 @@ fn handle_no_hit<O>(
|
|||||||
overlays.edit_overlay(hovered_id, false, app);
|
overlays.edit_overlay(hovered_id, false, app);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// in case click released while not aiming at anything
|
// in case click released while not aiming at anything
|
||||||
// send release event to overlay that was originally clicked
|
// send release event to overlay that was originally clicked
|
||||||
@@ -671,7 +670,7 @@ fn start_grab(
|
|||||||
}),
|
}),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
if let Some(hand) = pointer.hand().clone()
|
if let Some(hand) = pointer.hand()
|
||||||
&& !app.session.config.hide_grab_help
|
&& !app.session.config.hide_grab_help
|
||||||
{
|
{
|
||||||
let pos = state.positioning;
|
let pos = state.positioning;
|
||||||
@@ -708,6 +707,7 @@ fn handle_scale(transform: &mut Affine3A, scroll_y: f32) {
|
|||||||
.mul_scalar(0.025f32.mul_add(-scroll_y, 1.0));
|
.mul_scalar(0.025f32.mul_add(-scroll_y, 1.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
fn handle_grabbed<O>(idx: usize, overlay: &mut OverlayWindowData<O>, app: &mut AppState)
|
fn handle_grabbed<O>(idx: usize, overlay: &mut OverlayWindowData<O>, app: &mut AppState)
|
||||||
where
|
where
|
||||||
O: Default,
|
O: Default,
|
||||||
@@ -804,15 +804,14 @@ where
|
|||||||
x => x,
|
x => x,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else if overlay.config.global {
|
} else if overlay.config.global
|
||||||
if let Some(active_state) = overlay.config.active_state.as_ref() {
|
&& let Some(active_state) = overlay.config.active_state.as_ref()
|
||||||
|
{
|
||||||
let cur_scale = overlay.config.default_state.transform.x_axis.length();
|
let cur_scale = overlay.config.default_state.transform.x_axis.length();
|
||||||
let tgt_scale = active_state.transform.x_axis.length();
|
let tgt_scale = active_state.transform.x_axis.length();
|
||||||
|
|
||||||
let mat = &mut overlay.config.default_state.transform.matrix3;
|
let mat = &mut overlay.config.default_state.transform.matrix3;
|
||||||
*mat = mat.mul_scalar(tgt_scale / cur_scale);
|
*mat = mat.mul_scalar(tgt_scale / cur_scale);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
overlay.config.pause_movement = false;
|
overlay.config.pause_movement = false;
|
||||||
if let Some(overlay_state) = overlay.config.active_state.as_mut() {
|
if let Some(overlay_state) = overlay.config.active_state.as_mut() {
|
||||||
window::save_transform(overlay_state, app);
|
window::save_transform(overlay_state, app);
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ impl OverlayWindowData<OpenXrOverlayData> {
|
|||||||
.radius(radius)
|
.radius(radius)
|
||||||
.central_angle(angle)
|
.central_angle(angle)
|
||||||
.aspect_ratio(aspect_ratio);
|
.aspect_ratio(aspect_ratio);
|
||||||
layers.push(CompositionLayer::Cylinder(cylinder))
|
layers.push(CompositionLayer::Cylinder(cylinder));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let posef = helpers::transform_to_posef(&transform);
|
let posef = helpers::transform_to_posef(&transform);
|
||||||
@@ -125,7 +125,7 @@ impl OverlayWindowData<OpenXrOverlayData> {
|
|||||||
width: scale_x,
|
width: scale_x,
|
||||||
height: scale_y,
|
height: scale_y,
|
||||||
});
|
});
|
||||||
layers.push(CompositionLayer::Quad(quad))
|
layers.push(CompositionLayer::Quad(quad));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(layers)
|
Ok(layers)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ impl SwapchainOpts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::range_plus_one)]
|
||||||
pub(super) fn create_swapchain(
|
pub(super) fn create_swapchain(
|
||||||
xr: &XrState,
|
xr: &XrState,
|
||||||
gfx: Arc<WGfx>,
|
gfx: Arc<WGfx>,
|
||||||
@@ -78,7 +79,7 @@ pub(super) fn create_swapchain(
|
|||||||
let image = Arc::new(unsafe { raw_image.assume_bound() });
|
let image = Arc::new(unsafe { raw_image.assume_bound() });
|
||||||
let mut wsi = WlxSwapchainImage::default();
|
let mut wsi = WlxSwapchainImage::default();
|
||||||
for d in 0..extent[2] {
|
for d in 0..extent[2] {
|
||||||
let mut create_info = ImageViewCreateInfo::from_image(&*image);
|
let mut create_info = ImageViewCreateInfo::from_image(&image);
|
||||||
create_info.subresource_range.array_layers = d..d + 1;
|
create_info.subresource_range.array_layers = d..d + 1;
|
||||||
wsi.views.push(ImageView::new(image.clone(), create_info)?);
|
wsi.views.push(ImageView::new(image.clone(), create_info)?);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ pub enum PlayspaceTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
pub enum ModifyPanelCommand {
|
pub enum ModifyPanelCommand {
|
||||||
SetText(String),
|
SetText(String),
|
||||||
SetColor(String),
|
SetColor(String),
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ use crate::{
|
|||||||
windowing::OverlaySelector,
|
windowing::OverlaySelector,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
pub const BUTTON_EVENTS: [(
|
pub const BUTTON_EVENTS: [(
|
||||||
&str,
|
&str,
|
||||||
EventListenerKind,
|
EventListenerKind,
|
||||||
@@ -130,31 +131,31 @@ pub const BUTTON_EVENTS: [(
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
fn button_any(_: &mut CallbackData) -> bool {
|
const fn button_any(_: &mut CallbackData) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn button_left(data: &mut CallbackData) -> bool {
|
const fn button_left(data: &mut CallbackData) -> bool {
|
||||||
if let CallbackMetadata::MouseButton(b) = data.metadata
|
if let CallbackMetadata::MouseButton(b) = data.metadata
|
||||||
&& let MouseButtonIndex::Left = b.index
|
&& matches!(b.index, MouseButtonIndex::Left)
|
||||||
{
|
{
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn button_right(data: &mut CallbackData) -> bool {
|
const fn button_right(data: &mut CallbackData) -> bool {
|
||||||
if let CallbackMetadata::MouseButton(b) = data.metadata
|
if let CallbackMetadata::MouseButton(b) = data.metadata
|
||||||
&& let MouseButtonIndex::Right = b.index
|
&& matches!(b.index, MouseButtonIndex::Right)
|
||||||
{
|
{
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn button_middle(data: &mut CallbackData) -> bool {
|
const fn button_middle(data: &mut CallbackData) -> bool {
|
||||||
if let CallbackMetadata::MouseButton(b) = data.metadata
|
if let CallbackMetadata::MouseButton(b) = data.metadata
|
||||||
&& let MouseButtonIndex::Middle = b.index
|
&& matches!(b.index, MouseButtonIndex::Middle)
|
||||||
{
|
{
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
@@ -162,7 +163,7 @@ fn button_middle(data: &mut CallbackData) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ignore_duration(_btn: &ComponentButton, _app: &AppState) -> bool {
|
const fn ignore_duration(_btn: &ComponentButton, _app: &AppState) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
fn long_duration(btn: &ComponentButton, app: &AppState) -> bool {
|
fn long_duration(btn: &ComponentButton, app: &AppState) -> bool {
|
||||||
@@ -172,6 +173,7 @@ fn short_duration(btn: &ComponentButton, app: &AppState) -> bool {
|
|||||||
btn.get_time_since_last_pressed().as_secs_f32() < app.session.config.long_press_duration
|
btn.get_time_since_last_pressed().as_secs_f32() < app.session.config.long_press_duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
pub(super) fn setup_custom_button<S: 'static>(
|
pub(super) fn setup_custom_button<S: 'static>(
|
||||||
layout: &mut Layout,
|
layout: &mut Layout,
|
||||||
attribs: &CustomAttribsInfoOwned,
|
attribs: &CustomAttribsInfoOwned,
|
||||||
@@ -442,7 +444,7 @@ fn shell_on_action(state: &ShellButtonState) -> anyhow::Result<()> {
|
|||||||
let mut mut_state = state.mut_state.borrow_mut();
|
let mut mut_state = state.mut_state.borrow_mut();
|
||||||
|
|
||||||
if let Some(child) = mut_state.child.as_mut()
|
if let Some(child) = mut_state.child.as_mut()
|
||||||
&& let Ok(None) = child.try_wait()
|
&& matches!(child.try_wait(), Ok(None))
|
||||||
{
|
{
|
||||||
log::info!("ShellExec triggered while child is still running; sending SIGUSR1");
|
log::info!("ShellExec triggered while child is still running; sending SIGUSR1");
|
||||||
let _ = Command::new("kill")
|
let _ = Command::new("kill")
|
||||||
|
|||||||
@@ -103,10 +103,11 @@ impl<S: 'static> GuiPanel<S> {
|
|||||||
|
|
||||||
let doc_params = wgui::parser::ParseDocumentParams {
|
let doc_params = wgui::parser::ParseDocumentParams {
|
||||||
globals: app.wgui_globals.clone(),
|
globals: app.wgui_globals.clone(),
|
||||||
path: params
|
path: if params.external_xml {
|
||||||
.external_xml
|
AssetPath::File(path)
|
||||||
.then_some(AssetPath::File(path))
|
} else {
|
||||||
.unwrap_or(AssetPath::FileOrBuiltIn(path)),
|
AssetPath::FileOrBuiltIn(path)
|
||||||
|
},
|
||||||
extra: wgui::parser::ParseDocumentExtra {
|
extra: wgui::parser::ParseDocumentExtra {
|
||||||
on_custom_attribs: Some(Box::new({
|
on_custom_attribs: Some(Box::new({
|
||||||
let custom_elems = custom_elems.clone();
|
let custom_elems = custom_elems.clone();
|
||||||
@@ -311,7 +312,7 @@ impl<S: 'static> OverlayBackend for GuiPanel<S> {
|
|||||||
self.context.draw(
|
self.context.draw(
|
||||||
&globals.font_system,
|
&globals.font_system,
|
||||||
&mut app.wgui_shared,
|
&mut app.wgui_shared,
|
||||||
&mut rdr.cmd_buf_single(),
|
rdr.cmd_buf_single(),
|
||||||
&primitives,
|
&primitives,
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use crate::{
|
|||||||
fn process_tick_tasks(
|
fn process_tick_tasks(
|
||||||
tick_tasks: Vec<backend::wayvr::TickTask>,
|
tick_tasks: Vec<backend::wayvr::TickTask>,
|
||||||
server_state: &mut WvrServerState,
|
server_state: &mut WvrServerState,
|
||||||
) -> anyhow::Result<()> {
|
) {
|
||||||
for tick_task in tick_tasks {
|
for tick_task in tick_tasks {
|
||||||
match tick_task {
|
match tick_task {
|
||||||
backend::wayvr::TickTask::NewExternalProcess(request) => {
|
backend::wayvr::TickTask::NewExternalProcess(request) => {
|
||||||
@@ -30,8 +30,6 @@ fn process_tick_tasks(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tick_events<O>(
|
pub fn tick_events<O>(
|
||||||
@@ -69,7 +67,7 @@ where
|
|||||||
{
|
{
|
||||||
let tick_tasks = WvrServerState::tick_events(app)?;
|
let tick_tasks = WvrServerState::tick_events(app)?;
|
||||||
if let Some(wayvr_server) = app.wvr_server.as_mut() {
|
if let Some(wayvr_server) = app.wvr_server.as_mut() {
|
||||||
process_tick_tasks(tick_tasks, wayvr_server)?;
|
process_tick_tasks(tick_tasks, wayvr_server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ fn auto_run(args: Args) {
|
|||||||
|
|
||||||
let instructions = format!("Could not connect to runtime.\n{instructions}");
|
let instructions = format!("Could not connect to runtime.\n{instructions}");
|
||||||
|
|
||||||
let _ = DbusConnector::default().notify_send("WlxOverlay-S", &instructions, 1, 0, 0, false);
|
let _ = DbusConnector::notify_send("WlxOverlay-S", &instructions, 1, 0, 0, false);
|
||||||
|
|
||||||
#[cfg(not(any(feature = "openvr", feature = "openxr")))]
|
#[cfg(not(any(feature = "openvr", feature = "openxr")))]
|
||||||
compile_error!("No VR support! Enable either openvr or openxr features!");
|
compile_error!("No VR support! Enable either openvr or openxr features!");
|
||||||
@@ -200,6 +200,7 @@ const fn args_get_openxr(args: &Args) -> bool {
|
|||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::single_match_else)]
|
||||||
fn setup_signal_hooks() -> anyhow::Result<()> {
|
fn setup_signal_hooks() -> anyhow::Result<()> {
|
||||||
let mut signals = Signals::new([SIGINT, SIGTERM, SIGUSR1])?;
|
let mut signals = Signals::new([SIGINT, SIGTERM, SIGUSR1])?;
|
||||||
|
|
||||||
@@ -209,7 +210,6 @@ fn setup_signal_hooks() -> anyhow::Result<()> {
|
|||||||
SIGUSR1 => {
|
SIGUSR1 => {
|
||||||
log::info!("SIGUSR1 received (keymap changed)");
|
log::info!("SIGUSR1 received (keymap changed)");
|
||||||
KEYMAP_CHANGE.store(true, Ordering::Relaxed);
|
KEYMAP_CHANGE.store(true, Ordering::Relaxed);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
RUNNING.store(false, Ordering::Relaxed);
|
RUNNING.store(false, Ordering::Relaxed);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub fn create_custom(app: &mut AppState, name: Arc<str>) -> Option<OverlayWindow
|
|||||||
|
|
||||||
if let Err(e) = apply_custom_command(panel, app, &element, &command) {
|
if let Err(e) = apply_custom_command(panel, app, &element, &command) {
|
||||||
log::warn!("Could not apply {command:?} on {name}/{element}: {e:?}");
|
log::warn!("Could not apply {command:?} on {name}/{element}: {e:?}");
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ impl OverlayBackend for EditModeBackendWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
|
fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
|
||||||
let state = EditModeState {
|
let state = EditModeState {
|
||||||
id: Rc::new(RefCell::new(OverlayID::null())),
|
id: Rc::new(RefCell::new(OverlayID::null())),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ pub fn new_mouse_tab_handler(
|
|||||||
"mouse",
|
"mouse",
|
||||||
&MOUSE_NAMES,
|
&MOUSE_NAMES,
|
||||||
Box::new(|_common, state| {
|
Box::new(|_common, state| {
|
||||||
let mouse_transform = state.clone();
|
let mouse_transform = *state;
|
||||||
Box::new(move |app, owc| {
|
Box::new(move |app, owc| {
|
||||||
owc.backend
|
owc.backend
|
||||||
.set_attrib(app, BackendAttribValue::MouseTransform(mouse_transform));
|
.set_attrib(app, BackendAttribValue::MouseTransform(mouse_transform));
|
||||||
@@ -37,29 +37,29 @@ pub fn new_mouse_tab_handler(
|
|||||||
impl SpriteTabKey for MouseTransform {
|
impl SpriteTabKey for MouseTransform {
|
||||||
fn to_tab_key(&self) -> &'static str {
|
fn to_tab_key(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
MouseTransform::Default => "default",
|
Self::Default => "default",
|
||||||
MouseTransform::Normal => "normal",
|
Self::Normal => "normal",
|
||||||
MouseTransform::Rotated90 => "rotate90",
|
Self::Rotated90 => "rotate90",
|
||||||
MouseTransform::Rotated180 => "rotate180",
|
Self::Rotated180 => "rotate180",
|
||||||
MouseTransform::Rotated270 => "rotate270",
|
Self::Rotated270 => "rotate270",
|
||||||
MouseTransform::Flipped => "flipped",
|
Self::Flipped => "flipped",
|
||||||
MouseTransform::Flipped90 => "flip90",
|
Self::Flipped90 => "flip90",
|
||||||
MouseTransform::Flipped180 => "flip180",
|
Self::Flipped180 => "flip180",
|
||||||
MouseTransform::Flipped270 => "flip270",
|
Self::Flipped270 => "flip270",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_tab_key(key: &str) -> Self {
|
fn from_tab_key(key: &str) -> Self {
|
||||||
match key {
|
match key {
|
||||||
"default" => MouseTransform::Default,
|
"default" => Self::Default,
|
||||||
"normal" => MouseTransform::Normal,
|
"normal" => Self::Normal,
|
||||||
"rotate90" => MouseTransform::Rotated90,
|
"rotate90" => Self::Rotated90,
|
||||||
"rotate180" => MouseTransform::Rotated180,
|
"rotate180" => Self::Rotated180,
|
||||||
"rotate270" => MouseTransform::Rotated270,
|
"rotate270" => Self::Rotated270,
|
||||||
"flipped" => MouseTransform::Flipped,
|
"flipped" => Self::Flipped,
|
||||||
"flip90" => MouseTransform::Flipped90,
|
"flip90" => Self::Flipped90,
|
||||||
"flip180" => MouseTransform::Flipped180,
|
"flip180" => Self::Flipped180,
|
||||||
"flip270" => MouseTransform::Flipped270,
|
"flip270" => Self::Flipped270,
|
||||||
_ => {
|
_ => {
|
||||||
panic!("cannot translate to mouse transform: {key}")
|
panic!("cannot translate to mouse transform: {key}")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,27 +92,27 @@ impl SpriteTabKey for PosTabState {
|
|||||||
|
|
||||||
fn from_tab_key(key: &str) -> Self {
|
fn from_tab_key(key: &str) -> Self {
|
||||||
match key {
|
match key {
|
||||||
"static" => PosTabState {
|
"static" => Self {
|
||||||
pos: Positioning::Static,
|
pos: Positioning::Static,
|
||||||
has_lerp: false,
|
has_lerp: false,
|
||||||
has_align: false,
|
has_align: false,
|
||||||
},
|
},
|
||||||
"anchored" => PosTabState {
|
"anchored" => Self {
|
||||||
pos: Positioning::Anchored,
|
pos: Positioning::Anchored,
|
||||||
has_lerp: false,
|
has_lerp: false,
|
||||||
has_align: false,
|
has_align: false,
|
||||||
},
|
},
|
||||||
"floating" => PosTabState {
|
"floating" => Self {
|
||||||
pos: Positioning::Floating,
|
pos: Positioning::Floating,
|
||||||
has_lerp: false,
|
has_lerp: false,
|
||||||
has_align: false,
|
has_align: false,
|
||||||
},
|
},
|
||||||
"hmd" => PosTabState {
|
"hmd" => Self {
|
||||||
pos: Positioning::FollowHead { lerp: 1.0 },
|
pos: Positioning::FollowHead { lerp: 1.0 },
|
||||||
has_lerp: true,
|
has_lerp: true,
|
||||||
has_align: false,
|
has_align: false,
|
||||||
},
|
},
|
||||||
"hand_l" => PosTabState {
|
"hand_l" => Self {
|
||||||
pos: Positioning::FollowHand {
|
pos: Positioning::FollowHand {
|
||||||
hand: LeftRight::Left,
|
hand: LeftRight::Left,
|
||||||
lerp: 1.0,
|
lerp: 1.0,
|
||||||
@@ -121,7 +121,7 @@ impl SpriteTabKey for PosTabState {
|
|||||||
has_lerp: true,
|
has_lerp: true,
|
||||||
has_align: true,
|
has_align: true,
|
||||||
},
|
},
|
||||||
"hand_r" => PosTabState {
|
"hand_r" => Self {
|
||||||
pos: Positioning::FollowHand {
|
pos: Positioning::FollowHand {
|
||||||
hand: LeftRight::Right,
|
hand: LeftRight::Right,
|
||||||
lerp: 1.0,
|
lerp: 1.0,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ pub fn new_stereo_tab_handler(
|
|||||||
"stereo",
|
"stereo",
|
||||||
&STEREO_NAMES,
|
&STEREO_NAMES,
|
||||||
Box::new(|_common, state| {
|
Box::new(|_common, state| {
|
||||||
let stereo = state.clone();
|
let stereo = *state;
|
||||||
Box::new(move |app, owc| {
|
Box::new(move |app, owc| {
|
||||||
owc.backend
|
owc.backend
|
||||||
.set_attrib(app, BackendAttribValue::Stereo(stereo));
|
.set_attrib(app, BackendAttribValue::Stereo(stereo));
|
||||||
@@ -27,21 +27,21 @@ pub fn new_stereo_tab_handler(
|
|||||||
impl SpriteTabKey for StereoMode {
|
impl SpriteTabKey for StereoMode {
|
||||||
fn to_tab_key(&self) -> &'static str {
|
fn to_tab_key(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
StereoMode::None => "none",
|
Self::None => "none",
|
||||||
StereoMode::LeftRight => "leftright",
|
Self::LeftRight => "leftright",
|
||||||
StereoMode::RightLeft => "rightleft",
|
Self::RightLeft => "rightleft",
|
||||||
StereoMode::TopBottom => "topbottom",
|
Self::TopBottom => "topbottom",
|
||||||
StereoMode::BottomTop => "bottomtop",
|
Self::BottomTop => "bottomtop",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_tab_key(key: &str) -> Self {
|
fn from_tab_key(key: &str) -> Self {
|
||||||
match key {
|
match key {
|
||||||
"none" => StereoMode::None,
|
"none" => Self::None,
|
||||||
"leftright" => StereoMode::LeftRight,
|
"leftright" => Self::LeftRight,
|
||||||
"rightleft" => StereoMode::RightLeft,
|
"rightleft" => Self::RightLeft,
|
||||||
"topbottom" => StereoMode::TopBottom,
|
"topbottom" => Self::TopBottom,
|
||||||
"bottomtop" => StereoMode::BottomTop,
|
"bottomtop" => Self::BottomTop,
|
||||||
_ => {
|
_ => {
|
||||||
panic!("cannot translate to stereo mode: {key}")
|
panic!("cannot translate to stereo mode: {key}")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ pub(super) fn create_keyboard_panel(
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let has_altgr = keymap.as_ref().is_some_and(|m| XkbKeymap::has_altgr(*m));
|
let has_altgr = keymap.as_ref().is_some_and(|m| XkbKeymap::has_altgr(m));
|
||||||
|
|
||||||
let parse_doc_params = wgui::parser::ParseDocumentParams {
|
let parse_doc_params = wgui::parser::ParseDocumentParams {
|
||||||
globals,
|
globals,
|
||||||
|
|||||||
@@ -11,10 +11,13 @@ use crate::{
|
|||||||
gui::panel::GuiPanel,
|
gui::panel::GuiPanel,
|
||||||
overlays::keyboard::{builder::create_keyboard_panel, layout::AltModifier},
|
overlays::keyboard::{builder::create_keyboard_panel, layout::AltModifier},
|
||||||
state::AppState,
|
state::AppState,
|
||||||
subsystem::hid::{
|
subsystem::{
|
||||||
|
dbus::DbusConnector,
|
||||||
|
hid::{
|
||||||
ALT, CTRL, KeyModifier, META, SHIFT, SUPER, VirtualKey, WheelDelta, XkbKeymap,
|
ALT, CTRL, KeyModifier, META, SHIFT, SUPER, VirtualKey, WheelDelta, XkbKeymap,
|
||||||
get_keymap_wl, get_keymap_x11,
|
get_keymap_wl, get_keymap_x11,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
windowing::{
|
windowing::{
|
||||||
backend::{FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender},
|
backend::{FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender},
|
||||||
window::{OverlayCategory, OverlayWindowConfig},
|
window::{OverlayCategory, OverlayWindowConfig},
|
||||||
@@ -68,7 +71,7 @@ pub fn create_keyboard(app: &mut AppState, wayland: bool) -> anyhow::Result<Over
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut maybe_keymap = backend
|
let mut maybe_keymap = backend
|
||||||
.get_effective_keymap(app)
|
.get_effective_keymap()
|
||||||
.inspect_err(|e| log::warn!("{e:?}"))
|
.inspect_err(|e| log::warn!("{e:?}"))
|
||||||
.or_else(|_| {
|
.or_else(|_| {
|
||||||
if let Some(layout_variant) = app.session.config.default_keymap.as_ref() {
|
if let Some(layout_variant) = app.session.config.default_keymap.as_ref() {
|
||||||
@@ -142,7 +145,7 @@ impl KeyboardBackend {
|
|||||||
self.layout_ids.insert(layout_name.into(), id);
|
self.layout_ids.insert(layout_name.into(), id);
|
||||||
} else {
|
} else {
|
||||||
log::error!("XKB keymap without a layout!");
|
log::error!("XKB keymap without a layout!");
|
||||||
};
|
}
|
||||||
Ok(id)
|
Ok(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +187,7 @@ impl KeyboardBackend {
|
|||||||
.state = state_from;
|
.state = state_from;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_effective_keymap(&mut self, app: &mut AppState) -> anyhow::Result<XkbKeymap> {
|
fn get_effective_keymap(&mut self) -> anyhow::Result<XkbKeymap> {
|
||||||
fn get_system_keymap(wayland: bool) -> anyhow::Result<XkbKeymap> {
|
fn get_system_keymap(wayland: bool) -> anyhow::Result<XkbKeymap> {
|
||||||
if wayland {
|
if wayland {
|
||||||
get_keymap_wl()
|
get_keymap_wl()
|
||||||
@@ -193,9 +196,7 @@ impl KeyboardBackend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let Ok(fcitx_layout) = app
|
let Ok(fcitx_layout) = DbusConnector::fcitx_keymap()
|
||||||
.dbus
|
|
||||||
.fcitx_keymap()
|
|
||||||
.context("Could not keymap via fcitx5, falling back to wayland")
|
.context("Could not keymap via fcitx5, falling back to wayland")
|
||||||
.inspect_err(|e| log::info!("{e:?}"))
|
.inspect_err(|e| log::info!("{e:?}"))
|
||||||
else {
|
else {
|
||||||
@@ -204,8 +205,8 @@ impl KeyboardBackend {
|
|||||||
|
|
||||||
if let Some(captures) = self.re_fcitx.captures(&fcitx_layout) {
|
if let Some(captures) = self.re_fcitx.captures(&fcitx_layout) {
|
||||||
XkbKeymap::from_layout_variant(
|
XkbKeymap::from_layout_variant(
|
||||||
captures.get(1).map(|g| g.as_str()).unwrap_or(""),
|
captures.get(1).map_or("", |g| g.as_str()),
|
||||||
captures.get(2).map(|g| g.as_str()).unwrap_or(""),
|
captures.get(2).map_or("", |g| g.as_str()),
|
||||||
)
|
)
|
||||||
.context("layout/variant is invalid")
|
.context("layout/variant is invalid")
|
||||||
} else if SYSTEM_LAYOUT_ALIASES.contains(&fcitx_layout.as_str()) {
|
} else if SYSTEM_LAYOUT_ALIASES.contains(&fcitx_layout.as_str()) {
|
||||||
@@ -218,7 +219,7 @@ impl KeyboardBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn auto_switch_keymap(&mut self, app: &mut AppState) -> anyhow::Result<bool> {
|
fn auto_switch_keymap(&mut self, app: &mut AppState) -> anyhow::Result<bool> {
|
||||||
let keymap = self.get_effective_keymap(app)?;
|
let keymap = self.get_effective_keymap()?;
|
||||||
app.hid_provider
|
app.hid_provider
|
||||||
.keymap_changed(app.wvr_server.as_mut(), &keymap);
|
.keymap_changed(app.wvr_server.as_mut(), &keymap);
|
||||||
self.switch_keymap(&keymap, app)
|
self.switch_keymap(&keymap, app)
|
||||||
@@ -311,7 +312,7 @@ struct KeyboardState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl KeyboardState {
|
impl KeyboardState {
|
||||||
fn take(&mut self) -> Self {
|
const fn take(&mut self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
modifiers: self.modifiers,
|
modifiers: self.modifiers,
|
||||||
alt_modifier: self.alt_modifier,
|
alt_modifier: self.alt_modifier,
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ impl OverlayBackend for ScreenBackend {
|
|||||||
#[allow(unreachable_patterns)]
|
#[allow(unreachable_patterns)]
|
||||||
fn get_attrib(&self, attrib: BackendAttrib) -> Option<BackendAttribValue> {
|
fn get_attrib(&self, attrib: BackendAttrib) -> Option<BackendAttribValue> {
|
||||||
match attrib {
|
match attrib {
|
||||||
BackendAttrib::Stereo => self.stereo.map(|s| BackendAttribValue::Stereo(s)),
|
BackendAttrib::Stereo => self.stereo.map(BackendAttribValue::Stereo),
|
||||||
BackendAttrib::MouseTransform => Some(BackendAttribValue::MouseTransform(
|
BackendAttrib::MouseTransform => Some(BackendAttribValue::MouseTransform(
|
||||||
self.mouse_transform_override,
|
self.mouse_transform_override,
|
||||||
)),
|
)),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use wlx_capture::{
|
|||||||
};
|
};
|
||||||
use wlx_common::config::{PwTokenMap, def_pw_tokens};
|
use wlx_common::config::{PwTokenMap, def_pw_tokens};
|
||||||
|
|
||||||
use crate::{config_io, state::AppState};
|
use crate::{config_io, state::AppState, subsystem::dbus::DbusConnector};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
backend::ScreenBackend,
|
backend::ScreenBackend,
|
||||||
@@ -26,7 +26,6 @@ impl ScreenBackend {
|
|||||||
let embed_mouse = !app.session.config.double_cursor_fix;
|
let embed_mouse = !app.session.config.double_cursor_fix;
|
||||||
|
|
||||||
let select_screen_result = select_pw_screen(
|
let select_screen_result = select_pw_screen(
|
||||||
app,
|
|
||||||
&format!(
|
&format!(
|
||||||
"Now select: {} {} {} @ {},{}",
|
"Now select: {} {} {} @ {},{}",
|
||||||
&output.name,
|
&output.name,
|
||||||
@@ -63,7 +62,6 @@ impl ScreenBackend {
|
|||||||
|
|
||||||
#[allow(clippy::fn_params_excessive_bools)]
|
#[allow(clippy::fn_params_excessive_bools)]
|
||||||
pub(super) fn select_pw_screen(
|
pub(super) fn select_pw_screen(
|
||||||
app: &mut AppState,
|
|
||||||
instructions: &str,
|
instructions: &str,
|
||||||
token: Option<&str>,
|
token: Option<&str>,
|
||||||
embed_mouse: bool,
|
embed_mouse: bool,
|
||||||
@@ -87,7 +85,8 @@ 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(id) = app.dbus.notify_send(instructions, "", 2, 30, 0, true) {
|
if let Ok(id) = DbusConnector::notify_send(instructions, "", 2, 30, 0, true)
|
||||||
|
{
|
||||||
notify = Some(id);
|
notify = Some(id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -103,7 +102,7 @@ pub(super) fn select_pw_screen(
|
|||||||
let result = f.await;
|
let result = f.await;
|
||||||
if let Some(id) = notify {
|
if let Some(id) = notify {
|
||||||
//safe unwrap; checked above
|
//safe unwrap; checked above
|
||||||
let _ = app.dbus.notify_close(id);
|
let _ = DbusConnector::notify_close(id);
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ pub fn create_screens_x11pw(app: &mut AppState) -> anyhow::Result<ScreenCreateDa
|
|||||||
let embed_mouse = !app.session.config.double_cursor_fix;
|
let embed_mouse = !app.session.config.double_cursor_fix;
|
||||||
|
|
||||||
let select_screen_result = select_pw_screen(
|
let select_screen_result = select_pw_screen(
|
||||||
app,
|
|
||||||
"Select ALL screens on the screencast pop-up!",
|
"Select ALL screens on the screencast pop-up!",
|
||||||
token,
|
token,
|
||||||
embed_mouse,
|
embed_mouse,
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ struct WatchState {
|
|||||||
|
|
||||||
#[allow(clippy::significant_drop_tightening)]
|
#[allow(clippy::significant_drop_tightening)]
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
|
#[allow(clippy::cognitive_complexity)]
|
||||||
pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||||
let state = WatchState::default();
|
let state = WatchState::default();
|
||||||
|
|
||||||
@@ -192,12 +193,11 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let watch_xml = app
|
let watch_xml = if app.session.config.single_set_mode {
|
||||||
.session
|
"gui/watch-noset.xml"
|
||||||
.config
|
} else {
|
||||||
.single_set_mode
|
"gui/watch.xml"
|
||||||
.then_some("gui/watch-noset.xml")
|
};
|
||||||
.unwrap_or("gui/watch.xml");
|
|
||||||
|
|
||||||
let mut panel = GuiPanel::new_from_template(
|
let mut panel = GuiPanel::new_from_template(
|
||||||
app,
|
app,
|
||||||
@@ -234,9 +234,8 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
|||||||
for idx in 0..MAX_TOOLBOX_BUTTONS {
|
for idx in 0..MAX_TOOLBOX_BUTTONS {
|
||||||
let id_str = format!("overlay_{idx}");
|
let id_str = format!("overlay_{idx}");
|
||||||
|
|
||||||
let button = if let Some(button) = parser_state
|
let button = if let Ok(button) =
|
||||||
.fetch_component_as::<ComponentButton>(&id_str)
|
parser_state.fetch_component_as::<ComponentButton>(&id_str)
|
||||||
.ok()
|
|
||||||
{
|
{
|
||||||
button
|
button
|
||||||
} else {
|
} else {
|
||||||
@@ -438,7 +437,7 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
|||||||
if let Some(btn_dashboard) = btn_dashboard.as_ref() {
|
if let Some(btn_dashboard) = btn_dashboard.as_ref() {
|
||||||
btn_dashboard.set_sticky_state(&mut com, meta.visible);
|
btn_dashboard.set_sticky_state(&mut com, meta.visible);
|
||||||
}
|
}
|
||||||
panel.state.dashboard_oid = meta.id
|
panel.state.dashboard_oid = meta.id;
|
||||||
}
|
}
|
||||||
OverlayCategory::Internal => {}
|
OverlayCategory::Internal => {}
|
||||||
_ => panel.state.overlay_metas.push(meta),
|
_ => panel.state.overlay_metas.push(meta),
|
||||||
@@ -452,10 +451,11 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
|||||||
|
|
||||||
for (idx, btn) in panel.state.overlay_buttons.iter().enumerate() {
|
for (idx, btn) in panel.state.overlay_buttons.iter().enumerate() {
|
||||||
let display = if let Some(meta) = panel.state.overlay_metas.get(idx) {
|
let display = if let Some(meta) = panel.state.overlay_metas.get(idx) {
|
||||||
let name = btn
|
let name = if btn.condensed {
|
||||||
.condensed
|
condense_overlay_name(&meta.name)
|
||||||
.then(|| condense_overlay_name(&meta.name))
|
} else {
|
||||||
.unwrap_or_else(|| sanitize_overlay_name(&meta.name));
|
sanitize_overlay_name(&meta.name)
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(mut label) =
|
if let Some(mut label) =
|
||||||
panel.layout.state.widgets.get_as::<WidgetLabel>(btn.label)
|
panel.layout.state.widgets.get_as::<WidgetLabel>(btn.label)
|
||||||
@@ -487,14 +487,14 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
OverlayEventData::VisibleOverlaysChanged(overlays) => {
|
OverlayEventData::VisibleOverlaysChanged(overlays) => {
|
||||||
for meta in panel.state.overlay_metas.iter_mut() {
|
for meta in &mut panel.state.overlay_metas {
|
||||||
meta.visible = false;
|
meta.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut keyboard_visible = false;
|
let mut keyboard_visible = false;
|
||||||
let mut dashboard_visible = false;
|
let mut dashboard_visible = false;
|
||||||
|
|
||||||
for visible in overlays.iter() {
|
for visible in &overlays {
|
||||||
if let Some(idx) = panel.state.overlay_indices.get(*visible)
|
if let Some(idx) = panel.state.overlay_indices.get(*visible)
|
||||||
&& let Some(o) = panel.state.overlay_metas.get_mut(*idx)
|
&& let Some(o) = panel.state.overlay_metas.get_mut(*idx)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ impl OverlayBackend for WvrWindowBackend {
|
|||||||
log::trace!(
|
log::trace!(
|
||||||
"{}: new {} image",
|
"{}: new {} image",
|
||||||
self.name,
|
self.name,
|
||||||
surf.dmabuf.then_some("DMA-buf").unwrap_or("SHM")
|
if surf.dmabuf { "DMA-buf" } else { "SHM" }
|
||||||
);
|
);
|
||||||
self.cur_image = Some(surf.image);
|
self.cur_image = Some(surf.image);
|
||||||
Ok(ShouldRender::Should)
|
Ok(ShouldRender::Should)
|
||||||
@@ -183,8 +183,8 @@ impl OverlayBackend for WvrWindowBackend {
|
|||||||
.map(|m| {
|
.map(|m| {
|
||||||
let extent = image.extent_f32();
|
let extent = image.extent_f32();
|
||||||
MouseMeta {
|
MouseMeta {
|
||||||
x: (m.x as f32) / (extent[0] as f32),
|
x: (m.x as f32) / extent[0],
|
||||||
y: (m.y as f32) / (extent[1] as f32),
|
y: (m.y as f32) / extent[1],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -207,15 +207,15 @@ impl OverlayBackend for WvrWindowBackend {
|
|||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
if let OverlayEventData::IdAssigned(oid) = event_data {
|
if let OverlayEventData::IdAssigned(oid) = event_data {
|
||||||
let wvr_server = app.wvr_server.as_mut().unwrap(); //never None
|
let wvr_server = app.wvr_server.as_mut().unwrap(); //never None
|
||||||
wvr_server.overlay_added(oid, self.window.clone());
|
wvr_server.overlay_added(oid, self.window);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_hover(&mut self, app: &mut state::AppState, hit: &input::PointerHit) -> HoverResult {
|
fn on_hover(&mut self, app: &mut state::AppState, hit: &input::PointerHit) -> HoverResult {
|
||||||
if let Some(meta) = self.meta.as_ref() {
|
if let Some(meta) = self.meta.as_ref() {
|
||||||
let x = ((hit.uv.x * (meta.extent[0] as f32)) as u32).max(0);
|
let x = (hit.uv.x * (meta.extent[0] as f32)) as u32;
|
||||||
let y = ((hit.uv.y * (meta.extent[1] as f32)) as u32).max(0);
|
let y = (hit.uv.y * (meta.extent[1] as f32)) as u32;
|
||||||
|
|
||||||
let wvr_server = app.wvr_server.as_mut().unwrap(); //never None
|
let wvr_server = app.wvr_server.as_mut().unwrap(); //never None
|
||||||
wvr_server.send_mouse_move(self.window, x, y);
|
wvr_server.send_mouse_move(self.window, x, y);
|
||||||
@@ -266,7 +266,7 @@ impl OverlayBackend for WvrWindowBackend {
|
|||||||
|
|
||||||
fn get_attrib(&self, attrib: BackendAttrib) -> Option<BackendAttribValue> {
|
fn get_attrib(&self, attrib: BackendAttrib) -> Option<BackendAttribValue> {
|
||||||
match attrib {
|
match attrib {
|
||||||
BackendAttrib::Stereo => self.stereo.map(|s| BackendAttribValue::Stereo(s)),
|
BackendAttrib::Stereo => self.stereo.map(BackendAttribValue::Stereo),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ impl AppState {
|
|||||||
|
|
||||||
let mut defaults = wgui::globals::Defaults::default();
|
let mut defaults = wgui::globals::Defaults::default();
|
||||||
|
|
||||||
|
{
|
||||||
|
#[allow(clippy::ref_option)]
|
||||||
fn apply_color(default: &mut drawing::Color, value: &Option<String>) {
|
fn apply_color(default: &mut drawing::Color, value: &Option<String>) {
|
||||||
if let Some(parsed) = value.as_ref().and_then(|c| parse_color_hex(c)) {
|
if let Some(parsed) = value.as_ref().and_then(|c| parse_color_hex(c)) {
|
||||||
*default = parsed;
|
*default = parsed;
|
||||||
@@ -114,6 +116,7 @@ impl AppState {
|
|||||||
apply_color(&mut defaults.danger_color, &session.config.color_danger);
|
apply_color(&mut defaults.danger_color, &session.config.color_danger);
|
||||||
apply_color(&mut defaults.faded_color, &session.config.color_faded);
|
apply_color(&mut defaults.faded_color, &session.config.color_faded);
|
||||||
apply_color(&mut defaults.bg_color, &session.config.color_background);
|
apply_color(&mut defaults.bg_color, &session.config.color_background);
|
||||||
|
}
|
||||||
|
|
||||||
defaults.animation_mult = 1. / session.config.animation_speed;
|
defaults.animation_mult = 1. / session.config.animation_speed;
|
||||||
defaults.rounding_mult = session.config.round_multiplier;
|
defaults.rounding_mult = session.config.round_multiplier;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ impl DbusConnector {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fcitx_keymap(&mut self) -> anyhow::Result<String> {
|
pub fn fcitx_keymap() -> anyhow::Result<String> {
|
||||||
let connection = Connection::new_session()?;
|
let connection = Connection::new_session()?;
|
||||||
let proxy = connection.with_proxy(
|
let proxy = connection.with_proxy(
|
||||||
"org.fcitx.Fcitx5",
|
"org.fcitx.Fcitx5",
|
||||||
@@ -85,14 +85,12 @@ impl DbusConnector {
|
|||||||
Duration::from_millis(500),
|
Duration::from_millis(500),
|
||||||
);
|
);
|
||||||
|
|
||||||
let result = proxy
|
proxy
|
||||||
.current_input_method()
|
.current_input_method()
|
||||||
.context("Could not get D-Bus response");
|
.context("Could not get D-Bus response")
|
||||||
result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify_send(
|
pub fn notify_send(
|
||||||
&mut self,
|
|
||||||
summary: &str,
|
summary: &str,
|
||||||
body: &str,
|
body: &str,
|
||||||
urgency: u8,
|
urgency: u8,
|
||||||
@@ -125,7 +123,7 @@ impl DbusConnector {
|
|||||||
Ok(retval)
|
Ok(retval)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify_close(&mut self, id: u32) -> anyhow::Result<()> {
|
pub fn notify_close(id: u32) -> anyhow::Result<()> {
|
||||||
let connection = Connection::new_session()?;
|
let connection = Connection::new_session()?;
|
||||||
|
|
||||||
let proxy = connection.with_proxy(
|
let proxy = connection.with_proxy(
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ impl XkbKeymap {
|
|||||||
None,
|
None,
|
||||||
xkb::COMPILE_NO_FLAGS,
|
xkb::COMPILE_NO_FLAGS,
|
||||||
)
|
)
|
||||||
.map(|inner| XkbKeymap { inner })
|
.map(|inner| Self { inner })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_name(&self) -> Option<&str> {
|
pub fn get_name(&self) -> Option<&str> {
|
||||||
|
|||||||
@@ -119,7 +119,6 @@ impl Dispatch<WlKeyboard, ()> for MonitorState {
|
|||||||
Ok(Some(keymap)) => {
|
Ok(Some(keymap)) => {
|
||||||
for l in keymap.layouts() {
|
for l in keymap.layouts() {
|
||||||
log::info!("wayland keymap: {l}");
|
log::info!("wayland keymap: {l}");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state.keymap = Some(XkbKeymap { inner: keymap });
|
state.keymap = Some(XkbKeymap { inner: keymap });
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ impl NotificationManager {
|
|||||||
.with_path("/org/freedesktop/Notifications");
|
.with_path("/org/freedesktop/Notifications");
|
||||||
|
|
||||||
let sender = self.tx_toast.clone();
|
let sender = self.tx_toast.clone();
|
||||||
if let Ok(_) = dbus
|
if dbus
|
||||||
.become_monitor(
|
.become_monitor(
|
||||||
rule.clone(),
|
rule.clone(),
|
||||||
Box::new(move |msg, _| {
|
Box::new(move |msg, _| {
|
||||||
@@ -61,6 +61,7 @@ impl NotificationManager {
|
|||||||
)
|
)
|
||||||
.context("Could not register BecomeMonitor")
|
.context("Could not register BecomeMonitor")
|
||||||
.inspect_err(|e| log::warn!("{e:?}"))
|
.inspect_err(|e| log::warn!("{e:?}"))
|
||||||
|
.is_ok()
|
||||||
{
|
{
|
||||||
log::info!("Listening to D-Bus notifications via BecomeMonitor.");
|
log::info!("Listening to D-Bus notifications via BecomeMonitor.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ where
|
|||||||
me.add(grab_help, app);
|
me.add(grab_help, app);
|
||||||
|
|
||||||
let custom_panels = app.session.config.custom_panels.clone();
|
let custom_panels = app.session.config.custom_panels.clone();
|
||||||
for name in custom_panels.into_iter() {
|
for name in custom_panels {
|
||||||
let Some(panel) = create_custom(app, name) else {
|
let Some(panel) = create_custom(app, name) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
@@ -159,6 +159,7 @@ where
|
|||||||
Ok(me)
|
Ok(me)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
pub fn handle_task(&mut self, app: &mut AppState, task: OverlayTask) -> anyhow::Result<()> {
|
pub fn handle_task(&mut self, app: &mut AppState, task: OverlayTask) -> anyhow::Result<()> {
|
||||||
match task {
|
match task {
|
||||||
OverlayTask::ShowHide => self.show_hide(app),
|
OverlayTask::ShowHide => self.show_hide(app),
|
||||||
@@ -446,7 +447,7 @@ impl<T> OverlayWindowManager<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (name, attribs) in &app.session.config.attribs.clone() {
|
for (name, attribs) in &app.session.config.attribs.clone() {
|
||||||
let Some(oid) = self.lookup(&*name) else {
|
let Some(oid) = self.lookup(name) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Some(o) = self.mut_by_id(oid) else {
|
let Some(o) = self.mut_by_id(oid) else {
|
||||||
|
|||||||
Reference in New Issue
Block a user