Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TTWNO committed Jan 3, 2023
1 parent 31c3bcb commit 0a79647
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
7 changes: 3 additions & 4 deletions odilia/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio::sync::{
use crate::state::ScreenReaderState;
use atspi::{
accessible::Role,
accessible_ext::{AccessibleExt, MatcherArgs, AccessibleId},
accessible_ext::{AccessibleExt, MatcherArgs},
collection::MatchType,
component::ScrollType,
convertable::Convertable,
Expand All @@ -22,7 +22,6 @@ use atspi::{
};
use odilia_common::{
events::{Direction, ScreenReaderEvent},
modes::ScreenReaderMode,
result::OdiliaResult,
};
use ssip_client::Priority;
Expand Down Expand Up @@ -51,10 +50,10 @@ pub async fn structural_navigation(
if let Some(next) = curr.get_next(&mt, dir == Direction::Backward).await? {
let comp = next.to_component().await?;
let texti = next.to_text().await?;
let focused = comp.grab_focus().await?;
let _ = comp.grab_focus().await?;
comp.scroll_to(ScrollType::TopLeft).await?;
state.update_accessible(curr.try_into().unwrap()).await;
let caret_offset = texti.set_caret_offset(0).await?;
let _ = texti.set_caret_offset(0).await?;
let role = next.get_role().await?;
let len = texti.character_count().await?;
let text = texti.get_text(0, len).await?;
Expand Down
10 changes: 2 additions & 8 deletions odilia/src/events/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ mod children_changed {
accessible.get_state(),
accessible.name(),
)?;
/*
let cache_item = CacheItem {
object: accessible.try_into().unwrap(),
app: app.try_into().unwrap(),
Expand All @@ -61,7 +60,6 @@ mod children_changed {
// finally, write data to the internal cache
state.cache.add(cache_item).await;
tracing::debug!("Add a single item to cache.");
*/
Ok(())
}
pub async fn remove(state: &ScreenReaderState, event: &ChildrenChangedEvent) -> eyre::Result<()> {
Expand All @@ -74,7 +72,7 @@ mod children_changed {

mod text_caret_moved {
use crate::state::ScreenReaderState;
use atspi::{accessible_ext::AccessibleId, convertable::Convertable, events::GenericEvent, identify::object::TextCaretMovedEvent, signify::Signified};
use atspi::{convertable::Convertable, identify::object::TextCaretMovedEvent, signify::Signified};
use ssip_client::Priority;

/// this must be checked *before* writing an accessible to the hsitory.
Expand All @@ -95,10 +93,6 @@ mod text_caret_moved {
// likewise when getting the second-most recently focused accessible; we need the second-most recent accessible because it is possible that a tab navigation happened, which focused something before (or after) the caret moved events gets called, meaning the second-most recent accessible may be the only different accessible.
// if the accessible is focused before the event happens, the last_accessible variable will be the same as current_accessible.
// if the accessible is focused after the event happens, then the last_accessible will be different
let last_last_accessible = match state.history_item(1).await? {
Some(acc) => acc,
None => return Ok(true),
};
let previous_caret_pos = state.previous_caret_position.get();
let current_accessible = state.new_accessible(event).await?;
// if we know that the previous caret position was not 0, and the current and previous accessibles are the same, we know that this is NOT a tab navigation.
Expand Down Expand Up @@ -135,7 +129,7 @@ mod text_caret_moved {

mod state_changed {
use crate::state::ScreenReaderState;
use atspi::{accessible_ext::{AccessibleId, AccessibleExt}, identify::{object::StateChangedEvent}, signify::Signified};
use atspi::{accessible_ext::{AccessibleExt}, identify::{object::StateChangedEvent}, signify::Signified};

pub async fn dispatch(state: &ScreenReaderState, event: &StateChangedEvent) -> eyre::Result<()> {
// Dispatch based on kind
Expand Down
5 changes: 3 additions & 2 deletions odilia/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use odilia_cache::{
AccessiblePrimitive,
};
use atspi::{
accessible::AccessibleProxy, accessible_ext::{AccessibleExt, AccessibleId}, cache::CacheProxy,
accessible::AccessibleProxy, accessible_ext::{AccessibleExt}, cache::CacheProxy,
convertable::Convertable, text::TextGranularity,
signify::Signified,
};
Expand Down Expand Up @@ -166,7 +166,7 @@ impl ScreenReaderState {
return false;
}
// this crashed ssip-client because the connection is automatically stopped when invalid text is sent; since the period character on a line by itself is the stop character, there's not much we can do except filter it out explicitly.
if text == ".".to_string() {
if text == *"." {
return false;
}
if self.ssip
Expand All @@ -179,6 +179,7 @@ impl ScreenReaderState {
true
}

#[allow(dead_code)]
pub async fn event_history_item(
&self,
index: usize
Expand Down

0 comments on commit 0a79647

Please sign in to comment.