From 9af64eb0b39bf34105891f08054dd8442b3473f1 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 14 Aug 2021 17:53:32 +0200 Subject: [PATCH] rustfmt Signed-off-by: Uli Schlachter --- anvil/src/xwayland/mod.rs | 6 ++-- anvil/src/xwayland/x11rb_event_source.rs | 38 +++++++++++++++++------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/anvil/src/xwayland/mod.rs b/anvil/src/xwayland/mod.rs index 68e14f3..f876dba 100644 --- a/anvil/src/xwayland/mod.rs +++ b/anvil/src/xwayland/mod.rs @@ -1,4 +1,6 @@ -use std::{cell::RefCell, collections::HashMap, convert::TryFrom, os::unix::net::UnixStream, rc::Rc, sync::Arc}; +use std::{ + cell::RefCell, collections::HashMap, convert::TryFrom, os::unix::net::UnixStream, rc::Rc, sync::Arc, +}; use smithay::{ reexports::wayland_server::{protocol::wl_surface::WlSurface, Client}, @@ -44,7 +46,7 @@ impl AnvilState { self.handle .insert_source(source, move |event, _, _| { match wm.borrow_mut().handle_event(event, &client) { - Ok(()) => {}, + Ok(()) => {} Err(err) => error!(log, "Error while handling X11 event: {}", err), } }) diff --git a/anvil/src/xwayland/x11rb_event_source.rs b/anvil/src/xwayland/x11rb_event_source.rs index db1b07b..694b434 100644 --- a/anvil/src/xwayland/x11rb_event_source.rs +++ b/anvil/src/xwayland/x11rb_event_source.rs @@ -5,7 +5,12 @@ use std::{ }; use x11rb::{ - connection::Connection as _, protocol::{Event, xproto::{CLIENT_MESSAGE_EVENT, Atom, ConnectionExt as _, ClientMessageEvent, EventMask, Window}}, rust_connection::RustConnection, + connection::Connection as _, + protocol::{ + xproto::{Atom, ClientMessageEvent, ConnectionExt as _, EventMask, Window, CLIENT_MESSAGE_EVENT}, + Event, + }, + rust_connection::RustConnection, }; use smithay::reexports::calloop::{ @@ -39,14 +44,26 @@ impl X11Source { /// the given window with the given type. The expectation is that this is a window that was /// created by us. Thus, the event reading thread will wake up and check an internal exit flag, /// then exit. - pub fn new(connection: Arc, close_window: Window, close_type: Atom, log: slog::Logger) -> Self { + pub fn new( + connection: Arc, + close_window: Window, + close_type: Atom, + log: slog::Logger, + ) -> Self { let (sender, channel) = sync_channel(5); let conn = Arc::clone(&connection); let log2 = log.clone(); let event_thread = Some(spawn(move || { run_event_thread(conn, sender, log2); })); - Self { connection, channel, event_thread, close_window, close_type, log } + Self { + connection, + channel, + event_thread, + close_window, + close_type, + log, + } } } @@ -66,7 +83,9 @@ impl Drop for X11Source { type_: self.close_type, data: [0; 20].into(), }; - let _ = self.connection.send_event(false, self.close_window, EventMask::NO_EVENT, event); + let _ = self + .connection + .send_event(false, self.close_window, EventMask::NO_EVENT, event); let _ = self.connection.flush(); // Wait for the worker thread to exit @@ -89,12 +108,11 @@ impl EventSource for X11Source { C: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret, { let log = self.log.clone(); - self.channel.process_events(readiness, token, move |event, meta| { - match event { + self.channel + .process_events(readiness, token, move |event, meta| match event { ChannelEvent::Closed => slog::warn!(log, "Event thread exited"), - ChannelEvent::Msg(event) => callback(event, meta) - } - }) + ChannelEvent::Msg(event) => callback(event, meta), + }) } fn register(&mut self, poll: &mut Poll, factory: &mut TokenFactory) -> IOResult<()> { @@ -131,7 +149,7 @@ fn run_event_thread(connection: Arc, sender: SyncSender, } }; match sender.send(event) { - Ok(()) => {}, + Ok(()) => {} Err(_) => { // The only possible error is that the other end of the channel was dropped. // This happens in X11Source's Drop impl.