Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A minor cleanup driven by clippy #15

Merged
merged 4 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ pub enum Event {
GlobalRemoved(u32),
GlobalInfo(u32, Box<[(&'static str, String)]>),
GlobalProperties(u32, std::collections::BTreeMap<String, String>),
ClientPermissions(u32, u32, Vec<pw::permissions::Permission>),
ClientPermissions(
u32,
// Let's keep this as similar to PipeWire's message as possible
#[allow(dead_code)] u32,
Vec<pw::permissions::Permission>,
),
ProfilerProfile(Vec<self::pods::profiler::Profiling>),
MetadataProperty {
id: u32,
Expand Down
69 changes: 37 additions & 32 deletions src/backend/pipewire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,40 @@ pub fn pipewire_thread(
pw::context::Context,
Connection,
Rc<pw::registry::Registry>,
) = match (|| -> Result<_, connection::Error> {
let mainloop = if mainloop_properties.is_empty() {
pw::main_loop::MainLoop::new(None)?
} else {
pw::main_loop::MainLoop::new(Some(
util::key_val_to_props(mainloop_properties.into_iter()).dict(),
))?
};

let context = pw::context::Context::new(&mainloop)?;
if context
.load_module("libpipewire-module-profiler", None, None)
.is_err()
{
eprintln!("Failed to load the profiler module. No profiler data will be available");
};

let connection = Connection::connect(&context, context_properties, remote)?;

let registry = connection.core().get_registry()?;

Ok((mainloop, context, connection, Rc::new(registry)))
})() {
Ok(instance) => instance,
Err(e) => {
eprintln!("Failed to connect to remote: {e}");

sx.send(Event::Stop).ok();

return;
) = {
let result = (|| -> Result<_, connection::Error> {
let mainloop = if mainloop_properties.is_empty() {
pw::main_loop::MainLoop::new(None)?
} else {
pw::main_loop::MainLoop::new(Some(
util::key_val_to_props(mainloop_properties.into_iter()).dict(),
))?
};

let context = pw::context::Context::new(&mainloop)?;
if context
.load_module("libpipewire-module-profiler", None, None)
.is_err()
{
eprintln!("Failed to load the profiler module. No profiler data will be available");
};

let connection = Connection::connect(&context, context_properties, remote)?;

let registry = connection.core().get_registry()?;

Ok((mainloop, context, connection, Rc::new(registry)))
})();

match result {
Ok(instance) => instance,
Err(e) => {
eprintln!("Failed to connect to remote: {e}");

sx.send(Event::Stop).ok();

return;
}
}
};
let core = connection.core();
Expand Down Expand Up @@ -270,12 +274,13 @@ pub fn pipewire_thread(
.ok();

let id = global.id;
match BoundGlobal::bind_to(&registry, global, &sx, {
let proxy_removed = {
let binds = binds.clone();
move || {
binds.borrow_mut().remove(&id);
}
}) {
};
match BoundGlobal::bind_to(&registry, global, &sx, proxy_removed) {
Ok(bound_global) => {
binds.borrow_mut().insert(id, bound_global);
}
Expand Down
16 changes: 8 additions & 8 deletions src/ui/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,14 @@ impl Graph {
}
}

let mut pointer_delta = egui::Vec2::ZERO;
if ui.ui_contains_pointer() // Can only be queried after the editor UI has been drawn
&& ui.input(|i| {
pointer_delta = i.pointer.delta();
i.pointer.secondary_down()
})
{
self.editor.pan_zoom.pan += pointer_delta;
// Can only be queried after the editor UI has been drawn
if ui.ui_contains_pointer() {
let (secondary_down, pointer_delta) =
ui.input(|i| (i.pointer.secondary_down(), i.pointer.delta()));

if secondary_down {
self.editor.pan_zoom.pan += pointer_delta;
}
}
});
}
Expand Down
Loading