clippy
This commit is contained in:
@@ -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) {
|
||||
log::warn!("Could not apply {command:?} on {name}/{element}: {e:?}");
|
||||
};
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -256,6 +256,7 @@ impl OverlayBackend for EditModeBackendWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
|
||||
let state = EditModeState {
|
||||
id: Rc::new(RefCell::new(OverlayID::null())),
|
||||
|
||||
@@ -24,7 +24,7 @@ pub fn new_mouse_tab_handler(
|
||||
"mouse",
|
||||
&MOUSE_NAMES,
|
||||
Box::new(|_common, state| {
|
||||
let mouse_transform = state.clone();
|
||||
let mouse_transform = *state;
|
||||
Box::new(move |app, owc| {
|
||||
owc.backend
|
||||
.set_attrib(app, BackendAttribValue::MouseTransform(mouse_transform));
|
||||
@@ -37,29 +37,29 @@ pub fn new_mouse_tab_handler(
|
||||
impl SpriteTabKey for MouseTransform {
|
||||
fn to_tab_key(&self) -> &'static str {
|
||||
match self {
|
||||
MouseTransform::Default => "default",
|
||||
MouseTransform::Normal => "normal",
|
||||
MouseTransform::Rotated90 => "rotate90",
|
||||
MouseTransform::Rotated180 => "rotate180",
|
||||
MouseTransform::Rotated270 => "rotate270",
|
||||
MouseTransform::Flipped => "flipped",
|
||||
MouseTransform::Flipped90 => "flip90",
|
||||
MouseTransform::Flipped180 => "flip180",
|
||||
MouseTransform::Flipped270 => "flip270",
|
||||
Self::Default => "default",
|
||||
Self::Normal => "normal",
|
||||
Self::Rotated90 => "rotate90",
|
||||
Self::Rotated180 => "rotate180",
|
||||
Self::Rotated270 => "rotate270",
|
||||
Self::Flipped => "flipped",
|
||||
Self::Flipped90 => "flip90",
|
||||
Self::Flipped180 => "flip180",
|
||||
Self::Flipped270 => "flip270",
|
||||
}
|
||||
}
|
||||
|
||||
fn from_tab_key(key: &str) -> Self {
|
||||
match key {
|
||||
"default" => MouseTransform::Default,
|
||||
"normal" => MouseTransform::Normal,
|
||||
"rotate90" => MouseTransform::Rotated90,
|
||||
"rotate180" => MouseTransform::Rotated180,
|
||||
"rotate270" => MouseTransform::Rotated270,
|
||||
"flipped" => MouseTransform::Flipped,
|
||||
"flip90" => MouseTransform::Flipped90,
|
||||
"flip180" => MouseTransform::Flipped180,
|
||||
"flip270" => MouseTransform::Flipped270,
|
||||
"default" => Self::Default,
|
||||
"normal" => Self::Normal,
|
||||
"rotate90" => Self::Rotated90,
|
||||
"rotate180" => Self::Rotated180,
|
||||
"rotate270" => Self::Rotated270,
|
||||
"flipped" => Self::Flipped,
|
||||
"flip90" => Self::Flipped90,
|
||||
"flip180" => Self::Flipped180,
|
||||
"flip270" => Self::Flipped270,
|
||||
_ => {
|
||||
panic!("cannot translate to mouse transform: {key}")
|
||||
}
|
||||
|
||||
@@ -92,27 +92,27 @@ impl SpriteTabKey for PosTabState {
|
||||
|
||||
fn from_tab_key(key: &str) -> Self {
|
||||
match key {
|
||||
"static" => PosTabState {
|
||||
"static" => Self {
|
||||
pos: Positioning::Static,
|
||||
has_lerp: false,
|
||||
has_align: false,
|
||||
},
|
||||
"anchored" => PosTabState {
|
||||
"anchored" => Self {
|
||||
pos: Positioning::Anchored,
|
||||
has_lerp: false,
|
||||
has_align: false,
|
||||
},
|
||||
"floating" => PosTabState {
|
||||
"floating" => Self {
|
||||
pos: Positioning::Floating,
|
||||
has_lerp: false,
|
||||
has_align: false,
|
||||
},
|
||||
"hmd" => PosTabState {
|
||||
"hmd" => Self {
|
||||
pos: Positioning::FollowHead { lerp: 1.0 },
|
||||
has_lerp: true,
|
||||
has_align: false,
|
||||
},
|
||||
"hand_l" => PosTabState {
|
||||
"hand_l" => Self {
|
||||
pos: Positioning::FollowHand {
|
||||
hand: LeftRight::Left,
|
||||
lerp: 1.0,
|
||||
@@ -121,7 +121,7 @@ impl SpriteTabKey for PosTabState {
|
||||
has_lerp: true,
|
||||
has_align: true,
|
||||
},
|
||||
"hand_r" => PosTabState {
|
||||
"hand_r" => Self {
|
||||
pos: Positioning::FollowHand {
|
||||
hand: LeftRight::Right,
|
||||
lerp: 1.0,
|
||||
|
||||
@@ -14,7 +14,7 @@ pub fn new_stereo_tab_handler(
|
||||
"stereo",
|
||||
&STEREO_NAMES,
|
||||
Box::new(|_common, state| {
|
||||
let stereo = state.clone();
|
||||
let stereo = *state;
|
||||
Box::new(move |app, owc| {
|
||||
owc.backend
|
||||
.set_attrib(app, BackendAttribValue::Stereo(stereo));
|
||||
@@ -27,21 +27,21 @@ pub fn new_stereo_tab_handler(
|
||||
impl SpriteTabKey for StereoMode {
|
||||
fn to_tab_key(&self) -> &'static str {
|
||||
match self {
|
||||
StereoMode::None => "none",
|
||||
StereoMode::LeftRight => "leftright",
|
||||
StereoMode::RightLeft => "rightleft",
|
||||
StereoMode::TopBottom => "topbottom",
|
||||
StereoMode::BottomTop => "bottomtop",
|
||||
Self::None => "none",
|
||||
Self::LeftRight => "leftright",
|
||||
Self::RightLeft => "rightleft",
|
||||
Self::TopBottom => "topbottom",
|
||||
Self::BottomTop => "bottomtop",
|
||||
}
|
||||
}
|
||||
|
||||
fn from_tab_key(key: &str) -> Self {
|
||||
match key {
|
||||
"none" => StereoMode::None,
|
||||
"leftright" => StereoMode::LeftRight,
|
||||
"rightleft" => StereoMode::RightLeft,
|
||||
"topbottom" => StereoMode::TopBottom,
|
||||
"bottomtop" => StereoMode::BottomTop,
|
||||
"none" => Self::None,
|
||||
"leftright" => Self::LeftRight,
|
||||
"rightleft" => Self::RightLeft,
|
||||
"topbottom" => Self::TopBottom,
|
||||
"bottomtop" => Self::BottomTop,
|
||||
_ => {
|
||||
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 {
|
||||
globals,
|
||||
|
||||
@@ -11,9 +11,12 @@ use crate::{
|
||||
gui::panel::GuiPanel,
|
||||
overlays::keyboard::{builder::create_keyboard_panel, layout::AltModifier},
|
||||
state::AppState,
|
||||
subsystem::hid::{
|
||||
ALT, CTRL, KeyModifier, META, SHIFT, SUPER, VirtualKey, WheelDelta, XkbKeymap,
|
||||
get_keymap_wl, get_keymap_x11,
|
||||
subsystem::{
|
||||
dbus::DbusConnector,
|
||||
hid::{
|
||||
ALT, CTRL, KeyModifier, META, SHIFT, SUPER, VirtualKey, WheelDelta, XkbKeymap,
|
||||
get_keymap_wl, get_keymap_x11,
|
||||
},
|
||||
},
|
||||
windowing::{
|
||||
backend::{FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender},
|
||||
@@ -68,7 +71,7 @@ pub fn create_keyboard(app: &mut AppState, wayland: bool) -> anyhow::Result<Over
|
||||
};
|
||||
|
||||
let mut maybe_keymap = backend
|
||||
.get_effective_keymap(app)
|
||||
.get_effective_keymap()
|
||||
.inspect_err(|e| log::warn!("{e:?}"))
|
||||
.or_else(|_| {
|
||||
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);
|
||||
} else {
|
||||
log::error!("XKB keymap without a layout!");
|
||||
};
|
||||
}
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
@@ -184,7 +187,7 @@ impl KeyboardBackend {
|
||||
.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> {
|
||||
if wayland {
|
||||
get_keymap_wl()
|
||||
@@ -193,9 +196,7 @@ impl KeyboardBackend {
|
||||
}
|
||||
}
|
||||
|
||||
let Ok(fcitx_layout) = app
|
||||
.dbus
|
||||
.fcitx_keymap()
|
||||
let Ok(fcitx_layout) = DbusConnector::fcitx_keymap()
|
||||
.context("Could not keymap via fcitx5, falling back to wayland")
|
||||
.inspect_err(|e| log::info!("{e:?}"))
|
||||
else {
|
||||
@@ -204,8 +205,8 @@ impl KeyboardBackend {
|
||||
|
||||
if let Some(captures) = self.re_fcitx.captures(&fcitx_layout) {
|
||||
XkbKeymap::from_layout_variant(
|
||||
captures.get(1).map(|g| g.as_str()).unwrap_or(""),
|
||||
captures.get(2).map(|g| g.as_str()).unwrap_or(""),
|
||||
captures.get(1).map_or("", |g| g.as_str()),
|
||||
captures.get(2).map_or("", |g| g.as_str()),
|
||||
)
|
||||
.context("layout/variant is invalid")
|
||||
} 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> {
|
||||
let keymap = self.get_effective_keymap(app)?;
|
||||
let keymap = self.get_effective_keymap()?;
|
||||
app.hid_provider
|
||||
.keymap_changed(app.wvr_server.as_mut(), &keymap);
|
||||
self.switch_keymap(&keymap, app)
|
||||
@@ -311,7 +312,7 @@ struct KeyboardState {
|
||||
}
|
||||
|
||||
impl KeyboardState {
|
||||
fn take(&mut self) -> Self {
|
||||
const fn take(&mut self) -> Self {
|
||||
Self {
|
||||
modifiers: self.modifiers,
|
||||
alt_modifier: self.alt_modifier,
|
||||
|
||||
@@ -306,7 +306,7 @@ impl OverlayBackend for ScreenBackend {
|
||||
#[allow(unreachable_patterns)]
|
||||
fn get_attrib(&self, attrib: BackendAttrib) -> Option<BackendAttribValue> {
|
||||
match attrib {
|
||||
BackendAttrib::Stereo => self.stereo.map(|s| BackendAttribValue::Stereo(s)),
|
||||
BackendAttrib::Stereo => self.stereo.map(BackendAttribValue::Stereo),
|
||||
BackendAttrib::MouseTransform => Some(BackendAttribValue::MouseTransform(
|
||||
self.mouse_transform_override,
|
||||
)),
|
||||
|
||||
@@ -8,7 +8,7 @@ use wlx_capture::{
|
||||
};
|
||||
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::{
|
||||
backend::ScreenBackend,
|
||||
@@ -26,7 +26,6 @@ impl ScreenBackend {
|
||||
let embed_mouse = !app.session.config.double_cursor_fix;
|
||||
|
||||
let select_screen_result = select_pw_screen(
|
||||
app,
|
||||
&format!(
|
||||
"Now select: {} {} {} @ {},{}",
|
||||
&output.name,
|
||||
@@ -63,7 +62,6 @@ impl ScreenBackend {
|
||||
|
||||
#[allow(clippy::fn_params_excessive_bools)]
|
||||
pub(super) fn select_pw_screen(
|
||||
app: &mut AppState,
|
||||
instructions: &str,
|
||||
token: Option<&str>,
|
||||
embed_mouse: bool,
|
||||
@@ -87,7 +85,8 @@ pub(super) fn select_pw_screen(
|
||||
task::Poll::Pending => {
|
||||
if Instant::now() >= print_at {
|
||||
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);
|
||||
}
|
||||
break;
|
||||
@@ -103,7 +102,7 @@ pub(super) fn select_pw_screen(
|
||||
let result = f.await;
|
||||
if let Some(id) = notify {
|
||||
//safe unwrap; checked above
|
||||
let _ = app.dbus.notify_close(id);
|
||||
let _ = DbusConnector::notify_close(id);
|
||||
}
|
||||
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 select_screen_result = select_pw_screen(
|
||||
app,
|
||||
"Select ALL screens on the screencast pop-up!",
|
||||
token,
|
||||
embed_mouse,
|
||||
|
||||
@@ -69,6 +69,7 @@ struct WatchState {
|
||||
|
||||
#[allow(clippy::significant_drop_tightening)]
|
||||
#[allow(clippy::too_many_lines)]
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
let state = WatchState::default();
|
||||
|
||||
@@ -192,12 +193,11 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
}
|
||||
});
|
||||
|
||||
let watch_xml = app
|
||||
.session
|
||||
.config
|
||||
.single_set_mode
|
||||
.then_some("gui/watch-noset.xml")
|
||||
.unwrap_or("gui/watch.xml");
|
||||
let watch_xml = if app.session.config.single_set_mode {
|
||||
"gui/watch-noset.xml"
|
||||
} else {
|
||||
"gui/watch.xml"
|
||||
};
|
||||
|
||||
let mut panel = GuiPanel::new_from_template(
|
||||
app,
|
||||
@@ -234,9 +234,8 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
for idx in 0..MAX_TOOLBOX_BUTTONS {
|
||||
let id_str = format!("overlay_{idx}");
|
||||
|
||||
let button = if let Some(button) = parser_state
|
||||
.fetch_component_as::<ComponentButton>(&id_str)
|
||||
.ok()
|
||||
let button = if let Ok(button) =
|
||||
parser_state.fetch_component_as::<ComponentButton>(&id_str)
|
||||
{
|
||||
button
|
||||
} else {
|
||||
@@ -438,7 +437,7 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
if let Some(btn_dashboard) = btn_dashboard.as_ref() {
|
||||
btn_dashboard.set_sticky_state(&mut com, meta.visible);
|
||||
}
|
||||
panel.state.dashboard_oid = meta.id
|
||||
panel.state.dashboard_oid = meta.id;
|
||||
}
|
||||
OverlayCategory::Internal => {}
|
||||
_ => 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() {
|
||||
let display = if let Some(meta) = panel.state.overlay_metas.get(idx) {
|
||||
let name = btn
|
||||
.condensed
|
||||
.then(|| condense_overlay_name(&meta.name))
|
||||
.unwrap_or_else(|| sanitize_overlay_name(&meta.name));
|
||||
let name = if btn.condensed {
|
||||
condense_overlay_name(&meta.name)
|
||||
} else {
|
||||
sanitize_overlay_name(&meta.name)
|
||||
};
|
||||
|
||||
if let Some(mut 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) => {
|
||||
for meta in panel.state.overlay_metas.iter_mut() {
|
||||
for meta in &mut panel.state.overlay_metas {
|
||||
meta.visible = false;
|
||||
}
|
||||
|
||||
let mut keyboard_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)
|
||||
&& let Some(o) = panel.state.overlay_metas.get_mut(*idx)
|
||||
{
|
||||
|
||||
@@ -152,7 +152,7 @@ impl OverlayBackend for WvrWindowBackend {
|
||||
log::trace!(
|
||||
"{}: new {} image",
|
||||
self.name,
|
||||
surf.dmabuf.then_some("DMA-buf").unwrap_or("SHM")
|
||||
if surf.dmabuf { "DMA-buf" } else { "SHM" }
|
||||
);
|
||||
self.cur_image = Some(surf.image);
|
||||
Ok(ShouldRender::Should)
|
||||
@@ -183,8 +183,8 @@ impl OverlayBackend for WvrWindowBackend {
|
||||
.map(|m| {
|
||||
let extent = image.extent_f32();
|
||||
MouseMeta {
|
||||
x: (m.x as f32) / (extent[0] as f32),
|
||||
y: (m.y as f32) / (extent[1] as f32),
|
||||
x: (m.x as f32) / extent[0],
|
||||
y: (m.y as f32) / extent[1],
|
||||
}
|
||||
});
|
||||
|
||||
@@ -207,15 +207,15 @@ impl OverlayBackend for WvrWindowBackend {
|
||||
) -> anyhow::Result<()> {
|
||||
if let OverlayEventData::IdAssigned(oid) = event_data {
|
||||
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(())
|
||||
}
|
||||
|
||||
fn on_hover(&mut self, app: &mut state::AppState, hit: &input::PointerHit) -> HoverResult {
|
||||
if let Some(meta) = self.meta.as_ref() {
|
||||
let x = ((hit.uv.x * (meta.extent[0] as f32)) as u32).max(0);
|
||||
let y = ((hit.uv.y * (meta.extent[1] 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;
|
||||
|
||||
let wvr_server = app.wvr_server.as_mut().unwrap(); //never None
|
||||
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> {
|
||||
match attrib {
|
||||
BackendAttrib::Stereo => self.stereo.map(|s| BackendAttribValue::Stereo(s)),
|
||||
BackendAttrib::Stereo => self.stereo.map(BackendAttribValue::Stereo),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user