Skip to content

Commit

Permalink
clippy: fix warnings (#124)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <[email protected]>
  • Loading branch information
fenollp authored Jul 26, 2024
1 parent 6f8099d commit 76ed003
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 48 deletions.
8 changes: 1 addition & 7 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,7 @@ fn change_brush_width(app: &mut appctx::ApplicationContext<'_>, delta: i32) {
let current = G_DRAW_MODE.load(Ordering::Relaxed);
let current_size = current.get_size() as i32;
let proposed_size = current_size + delta;
let new_size = if proposed_size < 1 {
1
} else if proposed_size > 99 {
99
} else {
proposed_size
};
let new_size = proposed_size.clamp(1, 99);
if new_size == current_size {
return;
}
Expand Down
37 changes: 18 additions & 19 deletions src/appctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,22 +490,21 @@ impl<'a> ApplicationContext<'a> {
while self.running.load(Ordering::Relaxed) {
let event = self.input_rx.recv();
match event {
Err(e) => println!("Error in input event consumer: {0}", e),
Err(e) => eprintln!("Error in input event consumer: {e}"),
Ok(event) => {
if let InputEvent::MultitouchEvent { event } = event {
if let InputEvent::MultitouchEvent {
event: MultitouchEvent::Press { finger } | MultitouchEvent::Move { finger },
} = event
{
// Check for and notify clickable active regions for multitouch events
if let MultitouchEvent::Press { finger }
| MultitouchEvent::Move { finger } = event
{
let gseq = finger.tracking_id;
if last_active_region_gesture_id != gseq {
if let Some((h, _)) =
self.find_active_region(finger.pos.y, finger.pos.x)
{
(h.handler)(appref, h.element.clone());
}
last_active_region_gesture_id = gseq;
let gseq = finger.tracking_id;
if last_active_region_gesture_id != gseq {
if let Some((h, _)) =
self.find_active_region(finger.pos.y, finger.pos.x)
{
(h.handler)(appref, h.element.clone());
}
last_active_region_gesture_id = gseq;
}
}

Expand All @@ -522,13 +521,13 @@ impl<'a> ApplicationContext<'a> {
self.running.store(true, Ordering::Relaxed);

if self.running.load(Ordering::Relaxed) {
if let InputEvent::MultitouchEvent { event } = event {
if let InputEvent::MultitouchEvent {
event: MultitouchEvent::Press { finger } | MultitouchEvent::Move { finger },
} = event
{
// Check for and notify clickable active regions for multitouch events
if let MultitouchEvent::Press { finger } | MultitouchEvent::Move { finger } = event
{
if let Some((h, _)) = self.find_active_region(finger.pos.y, finger.pos.x) {
(h.handler)(appref, h.element.clone());
}
if let Some((h, _)) = self.find_active_region(finger.pos.y, finger.pos.x) {
(h.handler)(appref, h.element.clone());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/framebuffer/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl framebuffer::FramebufferDraw for core::Framebuffer {
unsafe {
libc::memset(
self.frame.as_mut_ptr() as *mut libc::c_void,
std::i32::MAX,
i32::MAX,
line_length * h,
);
}
Expand Down
16 changes: 8 additions & 8 deletions src/framebuffer/graphics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ where
let (min_xy, max_xy) = points.iter().fold(
(
Point2 {
y: std::i32::MAX,
x: std::i32::MAX,
y: i32::MAX,
x: i32::MAX,
},
Point2 {
y: std::i32::MIN,
x: std::i32::MIN,
y: i32::MIN,
x: i32::MIN,
},
),
|acc, p| {
Expand Down Expand Up @@ -239,12 +239,12 @@ where
let mut left_edge = Vec::<Point2<i32>>::new();
let mut right_edge = Vec::<Point2<i32>>::new();
let mut prev_left_pt = Point2 {
x: std::i32::MIN,
y: std::i32::MIN,
x: i32::MIN,
y: i32::MIN,
};
let mut prev_right_pt = Point2 {
x: std::i32::MIN,
y: std::i32::MIN,
x: i32::MIN,
y: i32::MIN,
};
for (t, pt) in sample_bezier(startpt.0, ctrlpt.0, endpt.0, samples) {
// interpolate width
Expand Down
22 changes: 11 additions & 11 deletions src/framebuffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,21 @@ pub trait FramebufferRefresh {
/// Some additional points to note:
///
/// 1) PxP must process 8x8 pixel blocks, and all pixels in each block
/// are considered for auto-waveform mode selection. If the
/// update region is not 8x8 aligned, additional unwanted pixels
/// will be considered in auto-waveform mode selection.
/// are considered for auto-waveform mode selection. If the
/// update region is not 8x8 aligned, additional unwanted pixels
/// will be considered in auto-waveform mode selection.
///
/// 2) PxP input must be 32-bit aligned, so any update
/// address not 32-bit aligned must be shifted to meet the
/// 32-bit alignment. The PxP will thus end up processing pixels
/// outside of the update region to satisfy this alignment restriction,
/// which can affect auto-waveform mode selection.
/// address not 32-bit aligned must be shifted to meet the
/// 32-bit alignment. The PxP will thus end up processing pixels
/// outside of the update region to satisfy this alignment restriction,
/// which can affect auto-waveform mode selection.
///
/// 3) If input fails 32-bit alignment, and the resulting expansion
/// of the processed region would add at least 8 pixels more per
/// line than the original update line width, the EPDC would
/// cause screen artifacts by incorrectly handling the 8+ pixels
/// at the end of each line.
/// of the processed region would add at least 8 pixels more per
/// line than the original update line width, the EPDC would
/// cause screen artifacts by incorrectly handling the 8+ pixels
/// at the end of each line.
#[allow(clippy::too_many_arguments)]
fn partial_refresh(
&self,
Expand Down
4 changes: 2 additions & 2 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ impl Default for Finger {
Finger {
tracking_id: -1, // -1 should never be seen by a InputEvent receiver
pos: cgmath::Point2 {
x: u16::max_value(),
y: u16::max_value(),
x: u16::MAX,
y: u16::MAX,
},
pos_updated: false,
last_pressed: false,
Expand Down

0 comments on commit 76ed003

Please sign in to comment.