Skip to content

Commit

Permalink
clippy: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
technobaboo committed Feb 9, 2025
1 parent 2996b03 commit 9f35e51
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 50 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ local_deps = ["stereokit-rust/force-local-deps"]
[package.metadata.appimage]
auto_link = true
auto_link_exclude_list = [
"libc*",
"libdl*",
"libpthread*",
"ld-linux*",
"libGL*",
"libEGL*",
"libc*",
"libdl*",
"libpthread*",
"ld-linux*",
"libGL*",
"libEGL*",
]

[profile.dev.package."*"]
Expand Down Expand Up @@ -97,9 +97,9 @@ xkbcommon-rs = "0.1.0"
# wayland
cluFlock = { version = "1.2.7", optional = true } # for the lockfile checking
waynest = { git = "https://github.com/technobaboo/waynest.git", features = [
"server",
"stable",
], optional = true }
"server",
"stable",
], default-features = false, optional = true }
tokio-stream = { version = "0.1.17", optional = true }
memmap2 = { version = "0.9.5", optional = true }

Expand All @@ -112,6 +112,5 @@ default-features = false

[dependencies.stardust-xr]
workspace = true

[dependencies.stardust-xr-server-codegen]
path = "codegen"
16 changes: 8 additions & 8 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,11 @@ pub fn run_client(mut command: Command, debug_launched_clients: bool) -> Option<
}

pub fn connection_env() -> FxHashMap<String, String> {
macro_rules! var_env_insert {
($env:ident, $name:ident) => {
$env.insert(stringify!($name).to_string(), $name.get().unwrap().clone());
};
}

let mut env: FxHashMap<String, String> = FxHashMap::default();
var_env_insert!(env, STARDUST_INSTANCE);
env.insert(
stringify!(STARDUST_INSTANCE).to_string(),
STARDUST_INSTANCE.get().unwrap().clone(),
);

if let Some(flat_wayland_display) = std::env::var_os("WAYLAND_DISPLAY") {
env.insert(
Expand All @@ -103,7 +100,10 @@ pub fn connection_env() -> FxHashMap<String, String> {
}
#[cfg(feature = "wayland")]
{
var_env_insert!(env, WAYLAND_DISPLAY);
env.insert(
stringify!(WAYLAND_DISPLAY).to_string(),
WAYLAND_DISPLAY.get().unwrap().to_string_lossy().to_string(),
);
env.insert("XDG_SESSION_TYPE".to_string(), "wayland".to_string());
}
env
Expand Down
7 changes: 5 additions & 2 deletions src/wayland/core/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ impl WlDisplay for Display {
) -> Result<()> {
let serial = client.next_event_serial();

let callback = Callback::default().into_object(callback_id);
tracing::info!(serial, "WlDisplay::sync");

let callback = Callback.into_object(callback_id);

callback
.as_dispatcher::<Callback>()?
Expand All @@ -45,7 +47,8 @@ impl WlDisplay for Display {
client: &mut Client,
registry_id: ObjectId,
) -> Result<()> {
let registry = Registry::default().into_object(registry_id);
tracing::info!("WlDisplay::get_registry");
let registry = Registry.into_object(registry_id);

registry
.as_dispatcher::<Registry>()?
Expand Down
16 changes: 5 additions & 11 deletions src/wayland/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,19 @@ impl WlRegistry for Registry {
new_id: NewId,
) -> Result<()> {
match name {
RegistryGlobals::COMPOSITOR => {
client.insert(Compositor::default().into_object(new_id.object_id))
}
RegistryGlobals::COMPOSITOR => client.insert(Compositor.into_object(new_id.object_id)),
RegistryGlobals::SHM => {
let shm = Shm::default().into_object(new_id.object_id);
let shm = Shm.into_object(new_id.object_id);

shm.as_dispatcher::<Shm>()?
.advertise_formats(&shm, client)
.await?;

client.insert(shm);
}
RegistryGlobals::WM_BASE => {
client.insert(WmBase::default().into_object(new_id.object_id))
}
RegistryGlobals::SEAT => client.insert(Seat::default().into_object(new_id.object_id)),
RegistryGlobals::OUTPUT => {
client.insert(Output::default().into_object(new_id.object_id))
}
RegistryGlobals::WM_BASE => client.insert(WmBase.into_object(new_id.object_id)),
RegistryGlobals::SEAT => client.insert(Seat.into_object(new_id.object_id)),
RegistryGlobals::OUTPUT => client.insert(Output.into_object(new_id.object_id)),
id => {
tracing::error!(id, "Wayland: failed to bind to registry global");
return Err(Error::Internal);
Expand Down
6 changes: 3 additions & 3 deletions src/wayland/core/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use waynest::{
wire::{Message, ObjectId},
};

pub const WL_SURFACE_REGISTRY: Registry<Surface> = Registry::new();
pub static WL_SURFACE_REGISTRY: Registry<Surface> = Registry::new();

#[derive(Debug, Clone)]
struct SurfaceState {
Expand Down Expand Up @@ -139,10 +139,10 @@ impl WlSurface for Surface {
client: &mut Client,
callback_id: ObjectId,
) -> Result<()> {
let callback = Callback::default().into_object(callback_id);
let callback = Callback.into_object(callback_id);
self.frame_callback
.lock()
.replace(Callback::default().done(&callback, 0));
.replace(Callback.done(&callback, 0));
client.insert(callback);
Ok(())
}
Expand Down
17 changes: 5 additions & 12 deletions src/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,12 @@ impl WaylandClient {
pub fn from_stream(socket: UnixStream) -> Result<Self> {
let pid = socket.peer_cred().ok().and_then(|c| c.pid());
let mut client = server::Client::new(socket)?;
let (message_tx, message_rx) = mpsc::unbounded_channel();
let (message_sink, message_source) = mpsc::unbounded_channel();

client.insert(
Display {
message_sink: message_tx,
pid,
}
.into_object(ObjectId::DISPLAY),
);
client.insert(Display { message_sink, pid }.into_object(ObjectId::DISPLAY));
let abort_handle = task::new(
|| "wayland client",
Self::handle_client_messages(client, message_rx),
Self::handle_client_messages(client, message_source),
)?
.abort_handle();

Expand Down Expand Up @@ -140,7 +134,6 @@ impl WaylandClient {
Ok(())
}
}

impl Drop for WaylandClient {
fn drop(&mut self) {
self.abort_handle.abort();
Expand All @@ -163,8 +156,8 @@ impl Wayland {

let _ = WAYLAND_DISPLAY.set(socket_path.clone());

let listener = server::Listener::new_with_path(&socket_path)
.map_err(|e| ServerError::WaylandError(e))?;
let listener =
server::Listener::new_with_path(&socket_path).map_err(ServerError::WaylandError)?;

let abort_handle =
task::new(|| "wayland loop", Self::handle_wayland_loop(listener))?.abort_handle();
Expand Down
3 changes: 1 addition & 2 deletions src/wayland/xdg/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ impl XdgSurface for Surface {
.unwrap()
.as_dispatcher::<Display>()
.unwrap()
.pid
.clone();
.pid;

let size = self.wl_surface.size().ok_or(server::Error::Internal)?;
client.insert(Toplevel::new(pid, size).into_object(id));
Expand Down

0 comments on commit 9f35e51

Please sign in to comment.