clippy
This commit is contained in:
@@ -375,17 +375,16 @@ where
|
||||
// focus change
|
||||
if let Some(hovered_id) = hovered_id
|
||||
&& 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) {
|
||||
old_hovered.primary_pointer = None;
|
||||
}
|
||||
log::debug!("{} on_left (focus changed)", old_hovered.config.name);
|
||||
old_hovered.config.backend.on_left(app, idx);
|
||||
old_hovered.hover_pointers[idx] = false;
|
||||
if !old_hovered.hover_pointers.iter().any(|x| *x) {
|
||||
overlays.edit_overlay(hovered_id, false, app);
|
||||
}
|
||||
if old_hovered.primary_pointer.is_some_and(|i| i == idx) {
|
||||
old_hovered.primary_pointer = None;
|
||||
}
|
||||
log::debug!("{} on_left (focus changed)", old_hovered.config.name);
|
||||
old_hovered.config.backend.on_left(app, idx);
|
||||
old_hovered.hover_pointers[idx] = false;
|
||||
if !old_hovered.hover_pointers.iter().any(|x| *x) {
|
||||
overlays.edit_overlay(hovered_id, false, app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,14 +471,14 @@ fn handle_no_hit<O>(
|
||||
overlays: &mut OverlayWindowManager<O>,
|
||||
app: &mut AppState,
|
||||
) {
|
||||
if let Some(hovered_id) = hovered_id {
|
||||
if let Some(hovered) = overlays.mut_by_id(hovered_id) {
|
||||
log::debug!("{} on_left (no hit)", hovered.config.name);
|
||||
hovered.config.backend.on_left(app, pointer_idx);
|
||||
hovered.hover_pointers[pointer_idx] = false;
|
||||
if !hovered.hover_pointers.iter().any(|x| *x) {
|
||||
overlays.edit_overlay(hovered_id, false, app);
|
||||
}
|
||||
if let Some(hovered_id) = hovered_id
|
||||
&& let Some(hovered) = overlays.mut_by_id(hovered_id)
|
||||
{
|
||||
log::debug!("{} on_left (no hit)", hovered.config.name);
|
||||
hovered.config.backend.on_left(app, pointer_idx);
|
||||
hovered.hover_pointers[pointer_idx] = false;
|
||||
if !hovered.hover_pointers.iter().any(|x| *x) {
|
||||
overlays.edit_overlay(hovered_id, false, app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn handle_grabbed<O>(idx: usize, overlay: &mut OverlayWindowData<O>, app: &mut AppState)
|
||||
where
|
||||
O: Default,
|
||||
@@ -804,14 +804,13 @@ where
|
||||
x => x,
|
||||
};
|
||||
}
|
||||
} else if overlay.config.global {
|
||||
if let Some(active_state) = overlay.config.active_state.as_ref() {
|
||||
let cur_scale = overlay.config.default_state.transform.x_axis.length();
|
||||
let tgt_scale = active_state.transform.x_axis.length();
|
||||
|
||||
let mat = &mut overlay.config.default_state.transform.matrix3;
|
||||
*mat = mat.mul_scalar(tgt_scale / cur_scale);
|
||||
}
|
||||
} else if overlay.config.global
|
||||
&& let Some(active_state) = overlay.config.active_state.as_ref()
|
||||
{
|
||||
let cur_scale = overlay.config.default_state.transform.x_axis.length();
|
||||
let tgt_scale = active_state.transform.x_axis.length();
|
||||
let mat = &mut overlay.config.default_state.transform.matrix3;
|
||||
*mat = mat.mul_scalar(tgt_scale / cur_scale);
|
||||
}
|
||||
overlay.config.pause_movement = false;
|
||||
if let Some(overlay_state) = overlay.config.active_state.as_mut() {
|
||||
|
||||
@@ -110,7 +110,7 @@ impl OverlayWindowData<OpenXrOverlayData> {
|
||||
.radius(radius)
|
||||
.central_angle(angle)
|
||||
.aspect_ratio(aspect_ratio);
|
||||
layers.push(CompositionLayer::Cylinder(cylinder))
|
||||
layers.push(CompositionLayer::Cylinder(cylinder));
|
||||
}
|
||||
} else {
|
||||
let posef = helpers::transform_to_posef(&transform);
|
||||
@@ -125,7 +125,7 @@ impl OverlayWindowData<OpenXrOverlayData> {
|
||||
width: scale_x,
|
||||
height: scale_y,
|
||||
});
|
||||
layers.push(CompositionLayer::Quad(quad))
|
||||
layers.push(CompositionLayer::Quad(quad));
|
||||
}
|
||||
}
|
||||
Ok(layers)
|
||||
|
||||
@@ -31,6 +31,7 @@ impl SwapchainOpts {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::range_plus_one)]
|
||||
pub(super) fn create_swapchain(
|
||||
xr: &XrState,
|
||||
gfx: Arc<WGfx>,
|
||||
@@ -78,7 +79,7 @@ pub(super) fn create_swapchain(
|
||||
let image = Arc::new(unsafe { raw_image.assume_bound() });
|
||||
let mut wsi = WlxSwapchainImage::default();
|
||||
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;
|
||||
wsi.views.push(ImageView::new(image.clone(), create_info)?);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ pub enum PlayspaceTask {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
pub enum ModifyPanelCommand {
|
||||
SetText(String),
|
||||
SetColor(String),
|
||||
|
||||
@@ -26,6 +26,7 @@ use crate::{
|
||||
windowing::OverlaySelector,
|
||||
};
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub const BUTTON_EVENTS: [(
|
||||
&str,
|
||||
EventListenerKind,
|
||||
@@ -130,31 +131,31 @@ pub const BUTTON_EVENTS: [(
|
||||
),
|
||||
];
|
||||
|
||||
fn button_any(_: &mut CallbackData) -> bool {
|
||||
const fn button_any(_: &mut CallbackData) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn button_left(data: &mut CallbackData) -> bool {
|
||||
const fn button_left(data: &mut CallbackData) -> bool {
|
||||
if let CallbackMetadata::MouseButton(b) = data.metadata
|
||||
&& let MouseButtonIndex::Left = b.index
|
||||
&& matches!(b.index, MouseButtonIndex::Left)
|
||||
{
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
fn button_right(data: &mut CallbackData) -> bool {
|
||||
const fn button_right(data: &mut CallbackData) -> bool {
|
||||
if let CallbackMetadata::MouseButton(b) = data.metadata
|
||||
&& let MouseButtonIndex::Right = b.index
|
||||
&& matches!(b.index, MouseButtonIndex::Right)
|
||||
{
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
fn button_middle(data: &mut CallbackData) -> bool {
|
||||
const fn button_middle(data: &mut CallbackData) -> bool {
|
||||
if let CallbackMetadata::MouseButton(b) = data.metadata
|
||||
&& let MouseButtonIndex::Middle = b.index
|
||||
&& matches!(b.index, MouseButtonIndex::Middle)
|
||||
{
|
||||
true
|
||||
} 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
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub(super) fn setup_custom_button<S: 'static>(
|
||||
layout: &mut Layout,
|
||||
attribs: &CustomAttribsInfoOwned,
|
||||
@@ -442,7 +444,7 @@ fn shell_on_action(state: &ShellButtonState) -> anyhow::Result<()> {
|
||||
let mut mut_state = state.mut_state.borrow_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");
|
||||
let _ = Command::new("kill")
|
||||
|
||||
@@ -103,10 +103,11 @@ impl<S: 'static> GuiPanel<S> {
|
||||
|
||||
let doc_params = wgui::parser::ParseDocumentParams {
|
||||
globals: app.wgui_globals.clone(),
|
||||
path: params
|
||||
.external_xml
|
||||
.then_some(AssetPath::File(path))
|
||||
.unwrap_or(AssetPath::FileOrBuiltIn(path)),
|
||||
path: if params.external_xml {
|
||||
AssetPath::File(path)
|
||||
} else {
|
||||
AssetPath::FileOrBuiltIn(path)
|
||||
},
|
||||
extra: wgui::parser::ParseDocumentExtra {
|
||||
on_custom_attribs: Some(Box::new({
|
||||
let custom_elems = custom_elems.clone();
|
||||
@@ -311,7 +312,7 @@ impl<S: 'static> OverlayBackend for GuiPanel<S> {
|
||||
self.context.draw(
|
||||
&globals.font_system,
|
||||
&mut app.wgui_shared,
|
||||
&mut rdr.cmd_buf_single(),
|
||||
rdr.cmd_buf_single(),
|
||||
&primitives,
|
||||
)?;
|
||||
Ok(())
|
||||
|
||||
@@ -17,7 +17,7 @@ use crate::{
|
||||
fn process_tick_tasks(
|
||||
tick_tasks: Vec<backend::wayvr::TickTask>,
|
||||
server_state: &mut WvrServerState,
|
||||
) -> anyhow::Result<()> {
|
||||
) {
|
||||
for tick_task in tick_tasks {
|
||||
match tick_task {
|
||||
backend::wayvr::TickTask::NewExternalProcess(request) => {
|
||||
@@ -30,8 +30,6 @@ fn process_tick_tasks(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn tick_events<O>(
|
||||
@@ -69,7 +67,7 @@ where
|
||||
{
|
||||
let tick_tasks = WvrServerState::tick_events(app)?;
|
||||
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 _ = 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")))]
|
||||
compile_error!("No VR support! Enable either openvr or openxr features!");
|
||||
@@ -200,6 +200,7 @@ const fn args_get_openxr(args: &Args) -> bool {
|
||||
ret
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match_else)]
|
||||
fn setup_signal_hooks() -> anyhow::Result<()> {
|
||||
let mut signals = Signals::new([SIGINT, SIGTERM, SIGUSR1])?;
|
||||
|
||||
@@ -209,7 +210,6 @@ fn setup_signal_hooks() -> anyhow::Result<()> {
|
||||
SIGUSR1 => {
|
||||
log::info!("SIGUSR1 received (keymap changed)");
|
||||
KEYMAP_CHANGE.store(true, Ordering::Relaxed);
|
||||
continue;
|
||||
}
|
||||
_ => {
|
||||
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) {
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,17 +103,20 @@ impl AppState {
|
||||
|
||||
let mut defaults = wgui::globals::Defaults::default();
|
||||
|
||||
fn apply_color(default: &mut drawing::Color, value: &Option<String>) {
|
||||
if let Some(parsed) = value.as_ref().and_then(|c| parse_color_hex(c)) {
|
||||
*default = parsed;
|
||||
{
|
||||
#[allow(clippy::ref_option)]
|
||||
fn apply_color(default: &mut drawing::Color, value: &Option<String>) {
|
||||
if let Some(parsed) = value.as_ref().and_then(|c| parse_color_hex(c)) {
|
||||
*default = parsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
apply_color(&mut defaults.text_color, &session.config.color_text);
|
||||
apply_color(&mut defaults.accent_color, &session.config.color_accent);
|
||||
apply_color(&mut defaults.danger_color, &session.config.color_danger);
|
||||
apply_color(&mut defaults.faded_color, &session.config.color_faded);
|
||||
apply_color(&mut defaults.bg_color, &session.config.color_background);
|
||||
apply_color(&mut defaults.text_color, &session.config.color_text);
|
||||
apply_color(&mut defaults.accent_color, &session.config.color_accent);
|
||||
apply_color(&mut defaults.danger_color, &session.config.color_danger);
|
||||
apply_color(&mut defaults.faded_color, &session.config.color_faded);
|
||||
apply_color(&mut defaults.bg_color, &session.config.color_background);
|
||||
}
|
||||
|
||||
defaults.animation_mult = 1. / session.config.animation_speed;
|
||||
defaults.rounding_mult = session.config.round_multiplier;
|
||||
|
||||
@@ -77,7 +77,7 @@ impl DbusConnector {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn fcitx_keymap(&mut self) -> anyhow::Result<String> {
|
||||
pub fn fcitx_keymap() -> anyhow::Result<String> {
|
||||
let connection = Connection::new_session()?;
|
||||
let proxy = connection.with_proxy(
|
||||
"org.fcitx.Fcitx5",
|
||||
@@ -85,14 +85,12 @@ impl DbusConnector {
|
||||
Duration::from_millis(500),
|
||||
);
|
||||
|
||||
let result = proxy
|
||||
proxy
|
||||
.current_input_method()
|
||||
.context("Could not get D-Bus response");
|
||||
result
|
||||
.context("Could not get D-Bus response")
|
||||
}
|
||||
|
||||
pub fn notify_send(
|
||||
&mut self,
|
||||
summary: &str,
|
||||
body: &str,
|
||||
urgency: u8,
|
||||
@@ -125,7 +123,7 @@ impl DbusConnector {
|
||||
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 proxy = connection.with_proxy(
|
||||
|
||||
@@ -590,7 +590,7 @@ impl XkbKeymap {
|
||||
None,
|
||||
xkb::COMPILE_NO_FLAGS,
|
||||
)
|
||||
.map(|inner| XkbKeymap { inner })
|
||||
.map(|inner| Self { inner })
|
||||
}
|
||||
|
||||
pub fn get_name(&self) -> Option<&str> {
|
||||
|
||||
@@ -119,7 +119,6 @@ impl Dispatch<WlKeyboard, ()> for MonitorState {
|
||||
Ok(Some(keymap)) => {
|
||||
for l in keymap.layouts() {
|
||||
log::info!("wayland keymap: {l}");
|
||||
break;
|
||||
}
|
||||
|
||||
state.keymap = Some(XkbKeymap { inner: keymap });
|
||||
|
||||
@@ -47,7 +47,7 @@ impl NotificationManager {
|
||||
.with_path("/org/freedesktop/Notifications");
|
||||
|
||||
let sender = self.tx_toast.clone();
|
||||
if let Ok(_) = dbus
|
||||
if dbus
|
||||
.become_monitor(
|
||||
rule.clone(),
|
||||
Box::new(move |msg, _| {
|
||||
@@ -61,6 +61,7 @@ impl NotificationManager {
|
||||
)
|
||||
.context("Could not register BecomeMonitor")
|
||||
.inspect_err(|e| log::warn!("{e:?}"))
|
||||
.is_ok()
|
||||
{
|
||||
log::info!("Listening to D-Bus notifications via BecomeMonitor.");
|
||||
return;
|
||||
|
||||
@@ -130,7 +130,7 @@ where
|
||||
me.add(grab_help, app);
|
||||
|
||||
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 {
|
||||
continue;
|
||||
};
|
||||
@@ -159,6 +159,7 @@ where
|
||||
Ok(me)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub fn handle_task(&mut self, app: &mut AppState, task: OverlayTask) -> anyhow::Result<()> {
|
||||
match task {
|
||||
OverlayTask::ShowHide => self.show_hide(app),
|
||||
@@ -446,7 +447,7 @@ impl<T> OverlayWindowManager<T> {
|
||||
}
|
||||
|
||||
for (name, attribs) in &app.session.config.attribs.clone() {
|
||||
let Some(oid) = self.lookup(&*name) else {
|
||||
let Some(oid) = self.lookup(name) else {
|
||||
continue;
|
||||
};
|
||||
let Some(o) = self.mut_by_id(oid) else {
|
||||
|
||||
Reference in New Issue
Block a user