cargo fmt
Pure formatting, no functional change. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
856f8d8bf4
commit
42ffe9c492
+1
-1
@@ -19,8 +19,8 @@ use nix::{
|
||||
use memmap2::MmapMut;
|
||||
|
||||
use wayland_client::{
|
||||
protocol::{wl_buffer, wl_shm, wl_shm_pool},
|
||||
Dispatch, QueueHandle,
|
||||
protocol::{wl_buffer, wl_shm, wl_shm_pool},
|
||||
};
|
||||
|
||||
use crate::color::Color;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::{
|
||||
event::Events,
|
||||
fonts::{find_font, FontMap},
|
||||
fonts::{FontMap, find_font},
|
||||
widgets::{
|
||||
Backlight, Battery, Calendar, Clock, Date, HorizontalLayout, IndexedLayout, Interface,
|
||||
InvertedHorizontalLayout, InvertedVerticalLayout, Layout, Line, Margin, PulseAudio,
|
||||
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
use crate::buffer::BufferView;
|
||||
use crate::{color::Color, fonts::FontRef};
|
||||
|
||||
use rusttype::{point, Scale};
|
||||
use rusttype::{Scale, point};
|
||||
use std::collections::HashMap;
|
||||
|
||||
struct CachedGlyph {
|
||||
@@ -121,7 +121,7 @@ impl<'a> Font<'a> {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
glyphs.push(glyph);
|
||||
@@ -154,7 +154,7 @@ impl<'a> Font<'a> {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
glyphs.push(glyph);
|
||||
@@ -206,7 +206,7 @@ impl<'a> Font<'a> {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
let width = glyph.advance;
|
||||
@@ -255,7 +255,7 @@ impl<'a> Font<'a> {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
glyphs.push(glyph);
|
||||
@@ -287,7 +287,7 @@ impl<'a> Font<'a> {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
glyphs.push(glyph);
|
||||
|
||||
+2
-5
@@ -12,12 +12,9 @@
|
||||
//! calloop event loop. Not doing so will prevent key repetition to work
|
||||
//! (but the rest of the functionnality will not be affected).
|
||||
|
||||
use std::{
|
||||
default::Default,
|
||||
os::unix::io::OwnedFd,
|
||||
};
|
||||
use std::{default::Default, os::unix::io::OwnedFd};
|
||||
|
||||
use wayland_client::{protocol::wl_keyboard, WEnum};
|
||||
use wayland_client::{WEnum, protocol::wl_keyboard};
|
||||
use xkbcommon::xkb;
|
||||
|
||||
pub use xkbcommon::xkb::keysyms;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use calloop::{
|
||||
EventSource, Poll, PostAction, Readiness, Token, TokenFactory,
|
||||
channel::{self, Channel},
|
||||
timer::{TimeoutAction, Timer},
|
||||
EventSource, Poll, PostAction, Readiness, Token, TokenFactory,
|
||||
};
|
||||
use wayland_client::{protocol::wl_keyboard, WEnum};
|
||||
use wayland_client::{WEnum, protocol::wl_keyboard};
|
||||
|
||||
use super::KeyEvent;
|
||||
|
||||
@@ -136,7 +136,9 @@ impl EventSource for KeyRepeatSource {
|
||||
let mut next_deadline = deadline;
|
||||
if now - deadline > *rate * 2 {
|
||||
// We're way behind, let's just set a new time
|
||||
println!("KeyRepeatSource::process_events: More than two repeat cycles behind, resetting");
|
||||
println!(
|
||||
"KeyRepeatSource::process_events: More than two repeat cycles behind, resetting"
|
||||
);
|
||||
next_deadline = now + *rate;
|
||||
} else {
|
||||
while next_deadline < now {
|
||||
|
||||
+3
-4
@@ -12,8 +12,8 @@ mod widgets;
|
||||
use wayland_client::{Connection, QueueHandle, WaylandSource};
|
||||
|
||||
use calloop::{
|
||||
timer::{TimeoutAction, Timer},
|
||||
EventLoop,
|
||||
timer::{TimeoutAction, Timer},
|
||||
};
|
||||
use chrono::{Duration, Local, Timelike};
|
||||
|
||||
@@ -30,12 +30,11 @@ use utils::{
|
||||
use widgets::{Geometry, Widget};
|
||||
|
||||
use std::{
|
||||
env,
|
||||
env, fs,
|
||||
fs::File,
|
||||
fs,
|
||||
path::Path,
|
||||
io::{BufRead, BufReader, Write},
|
||||
os::unix::net::{UnixListener, UnixStream},
|
||||
path::Path,
|
||||
rc::Rc,
|
||||
thread,
|
||||
};
|
||||
|
||||
+4
-2
@@ -7,11 +7,11 @@ use std::{
|
||||
};
|
||||
|
||||
use wayland_client::{
|
||||
Connection, Dispatch, QueueHandle, WEnum,
|
||||
protocol::{
|
||||
wl_buffer, wl_callback, wl_compositor, wl_keyboard, wl_pointer, wl_registry, wl_seat,
|
||||
wl_shm, wl_shm_pool, wl_subcompositor, wl_subsurface, wl_surface,
|
||||
},
|
||||
Connection, Dispatch, QueueHandle, WEnum,
|
||||
};
|
||||
|
||||
use wayland_protocols::{
|
||||
@@ -141,7 +141,9 @@ impl State {
|
||||
activation.activate(key, surface);
|
||||
let activation_token = activation.get_activation_token(qh, ());
|
||||
activation_token.commit();
|
||||
unsafe { env::remove_var("XDG_ACTIVATION_TOKEN"); }
|
||||
unsafe {
|
||||
env::remove_var("XDG_ACTIVATION_TOKEN");
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::{
|
||||
cmp::Ordering,
|
||||
collections::HashSet,
|
||||
error::Error,
|
||||
fs::{read_to_string, File},
|
||||
fs::{File, read_to_string},
|
||||
hash::{Hash, Hasher},
|
||||
io::{Error as io_error, ErrorKind},
|
||||
path::Path,
|
||||
@@ -104,7 +104,10 @@ pub fn load_desktop_files() -> Vec<Desktop> {
|
||||
let mut seen: HashSet<String> = HashSet::new();
|
||||
|
||||
for dir in dirs {
|
||||
for entry in WalkDir::new(format!("{}/applications", dir)).into_iter().flatten() {
|
||||
for entry in WalkDir::new(format!("{}/applications", dir))
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
// Entries are often symlinks, so only rule out directories.
|
||||
if entry.file_type().is_dir()
|
||||
|| entry.path().extension().and_then(|e| e.to_str()) != Some("desktop")
|
||||
|
||||
@@ -6,8 +6,8 @@ use std::{
|
||||
};
|
||||
|
||||
use dbus::blocking::{
|
||||
stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged},
|
||||
LocalConnection,
|
||||
stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -64,7 +64,10 @@ fn battery_present() -> Result<bool, Box<dyn Error>> {
|
||||
Ok(present)
|
||||
}
|
||||
|
||||
fn monitor(inner: Arc<Mutex<InnerBattery>>, events: Arc<Mutex<Events>>) -> Result<(), Box<dyn Error>> {
|
||||
fn monitor(
|
||||
inner: Arc<Mutex<InnerBattery>>,
|
||||
events: Arc<Mutex<Events>>,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let conn = LocalConnection::new_system()?;
|
||||
let proxy = conn.with_proxy(
|
||||
"org.freedesktop.UPower",
|
||||
|
||||
@@ -323,7 +323,7 @@ impl<'a> Widget for Calendar {
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
}
|
||||
};
|
||||
}
|
||||
x => x,
|
||||
};
|
||||
@@ -335,7 +335,7 @@ impl<'a> Widget for Calendar {
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
}
|
||||
};
|
||||
}
|
||||
y => y,
|
||||
};
|
||||
|
||||
+9
-13
@@ -1,10 +1,10 @@
|
||||
use std::{
|
||||
cmp::{max, min, Ordering},
|
||||
cmp::{Ordering, max, min},
|
||||
collections::HashMap,
|
||||
default::Default,
|
||||
fs::{read_to_string, File},
|
||||
fs::{File, read_to_string},
|
||||
io::Write,
|
||||
process::{exit, Command},
|
||||
process::{Command, exit},
|
||||
sync::{Arc, Mutex},
|
||||
thread,
|
||||
};
|
||||
@@ -14,18 +14,18 @@ use crate::{
|
||||
color::Color,
|
||||
event::{Event, Events, PointerButton, PointerEvent},
|
||||
fonts::FontMap,
|
||||
keyboard::{keysyms, KeyEvent},
|
||||
keyboard::{KeyEvent, keysyms},
|
||||
utils::{
|
||||
desktop::{load_desktop_cache, load_desktop_files, write_desktop_cache, Desktop},
|
||||
desktop::{Desktop, load_desktop_cache, load_desktop_files, write_desktop_cache},
|
||||
xdg,
|
||||
},
|
||||
widgets::{Geometry, Widget},
|
||||
};
|
||||
|
||||
use fuzzy_matcher::skim::SkimMatcherV2;
|
||||
use fuzzy_matcher::FuzzyMatcher;
|
||||
use fuzzy_matcher::skim::SkimMatcherV2;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use wayland_client::{protocol::wl_keyboard, WEnum};
|
||||
use wayland_client::{WEnum, protocol::wl_keyboard};
|
||||
|
||||
struct Matcher {
|
||||
matches: HashMap<Desktop, i64>,
|
||||
@@ -692,11 +692,7 @@ impl Interface {
|
||||
if line_height == 0 {
|
||||
return;
|
||||
}
|
||||
let height = self
|
||||
.inner
|
||||
.geometry
|
||||
.height
|
||||
.saturating_sub(line_height + 8);
|
||||
let height = self.inner.geometry.height.saturating_sub(line_height + 8);
|
||||
let lines = height / line_height;
|
||||
|
||||
let offset = height % line_height;
|
||||
@@ -847,7 +843,7 @@ impl Widget for Interface {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{strip_field_codes, Prompt, PromptMode};
|
||||
use super::{Prompt, PromptMode, strip_field_codes};
|
||||
|
||||
#[test]
|
||||
fn prompt_cursor_is_grapheme_based() {
|
||||
|
||||
@@ -26,13 +26,13 @@ fn monitor(
|
||||
use libpulse_binding::{
|
||||
callbacks::ListResult,
|
||||
context::{
|
||||
subscribe::{Facility, InterestMaskSet},
|
||||
Context, FlagSet, State,
|
||||
subscribe::{Facility, InterestMaskSet},
|
||||
},
|
||||
mainloop::{
|
||||
self, api::Mainloop, events::io::FlagSet as IoFlagSet, standard::IterateResult,
|
||||
},
|
||||
proplist::{properties, Proplist},
|
||||
proplist::{Proplist, properties},
|
||||
volume::Volume,
|
||||
};
|
||||
|
||||
@@ -50,14 +50,14 @@ fn monitor(
|
||||
loop {
|
||||
match mainloop.iterate(true) {
|
||||
IterateResult::Quit(_) | IterateResult::Err(_) => {
|
||||
return Err("pulseaudio mainloop quit while connecting".into())
|
||||
return Err("pulseaudio mainloop quit while connecting".into());
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
match context.borrow().get_state() {
|
||||
State::Ready => break,
|
||||
State::Failed | State::Terminated => {
|
||||
return Err("could not connect to pulseaudio".into())
|
||||
return Err("could not connect to pulseaudio".into());
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
@@ -88,6 +88,9 @@ mod tests {
|
||||
assert_eq!(e.x + e.width, 15);
|
||||
assert_eq!(e.y + e.height, 102);
|
||||
let e2 = b.expand(a);
|
||||
assert_eq!((e2.x, e2.y, e2.width, e2.height), (e.x, e.y, e.width, e.height));
|
||||
assert_eq!(
|
||||
(e2.x, e2.y, e2.width, e2.height),
|
||||
(e.x, e.y, e.width, e.height)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user