From bfad91d315ae8ef264a5fd73247ca8f6dedde340 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 23 May 2021 17:32:48 +0200 Subject: [PATCH] Make rustfmt happy Signed-off-by: Uli Schlachter --- druid-shell/src/platform/x11/application.rs | 4 +- druid-shell/src/platform/x11/clipboard.rs | 66 ++++++++++++++------- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/druid-shell/src/platform/x11/application.rs b/druid-shell/src/platform/x11/application.rs index 61e337cbfe..9f6d7cf3d6 100644 --- a/druid-shell/src/platform/x11/application.rs +++ b/druid-shell/src/platform/x11/application.rs @@ -25,7 +25,9 @@ use anyhow::{anyhow, Context, Error}; use x11rb::connection::Connection; use x11rb::protocol::present::ConnectionExt as _; use x11rb::protocol::xfixes::ConnectionExt as _; -use x11rb::protocol::xproto::{self, ConnectionExt, CreateWindowAux, EventMask, Timestamp, WindowClass}; +use x11rb::protocol::xproto::{ + self, ConnectionExt, CreateWindowAux, EventMask, Timestamp, WindowClass, +}; use x11rb::protocol::Event; use x11rb::resource_manager::Database as ResourceDb; use x11rb::xcb_ffi::XCBConnection; diff --git a/druid-shell/src/platform/x11/clipboard.rs b/druid-shell/src/platform/x11/clipboard.rs index d975fab02d..fe8d940009 100644 --- a/druid-shell/src/platform/x11/clipboard.rs +++ b/druid-shell/src/platform/x11/clipboard.rs @@ -20,8 +20,11 @@ use std::rc::Rc; use x11rb::connection::Connection; use x11rb::errors::ReplyOrIdError; +use x11rb::protocol::xproto::{ + AtomEnum, ChangeWindowAttributesAux, ConnectionExt, EventMask, GetPropertyType, Property, + Timestamp, WindowClass, +}; use x11rb::protocol::Event; -use x11rb::protocol::xproto::{AtomEnum, ChangeWindowAttributesAux, ConnectionExt, EventMask, GetPropertyType, Property, Timestamp, WindowClass}; use x11rb::xcb_ffi::XCBConnection; use crate::clipboard::{ClipboardFormat, FormatId}; @@ -53,7 +56,12 @@ impl Clipboard { event_queue: Rc>>, timestamp: Rc>, ) -> Self { - Clipboard { connection, screen_num, event_queue, timestamp } + Clipboard { + connection, + screen_num, + event_queue, + timestamp, + } } pub fn put_string(&mut self, _s: impl AsRef) { @@ -97,7 +105,11 @@ impl Clipboard { let format = conn.intern_atom(false, format.as_bytes())?; let clipboard = conn.intern_atom(false, b"CLIPBOARD")?; let incr = conn.intern_atom(false, b"INCR")?; - (format.reply()?.atom, clipboard.reply()?.atom, incr.reply()?.atom) + ( + format.reply()?.atom, + clipboard.reply()?.atom, + incr.reply()?.atom, + ) }; // Create a window for the transfer @@ -115,7 +127,9 @@ impl Clipboard { conn.flush()?; let notify = loop { match conn.wait_for_event()? { - Event::SelectionNotify(notify) if notify.requestor == window.window => break notify, + Event::SelectionNotify(notify) if notify.requestor == window.window => { + break notify + } event => self.event_queue.borrow_mut().push_back(event), } }; @@ -129,14 +143,16 @@ impl Clipboard { &ChangeWindowAttributesAux::default().event_mask(EventMask::PROPERTY_CHANGE), )?; - let property = conn.get_property( - true, - window.window, - TRANSFER_ATOM, - GetPropertyType::ANY, - 0, - u32::MAX, - )?.reply()?; + let property = conn + .get_property( + true, + window.window, + TRANSFER_ATOM, + GetPropertyType::ANY, + 0, + u32::MAX, + )? + .reply()?; if property.type_ != incr_atom { Ok(Some(property.value)) @@ -148,26 +164,30 @@ impl Clipboard { conn.flush()?; loop { match conn.wait_for_event()? { - Event::PropertyNotify(notify) if (notify.window, notify.state) == (window.window, Property::NEW_VALUE) => { - let property = conn.get_property( - true, - window.window, - TRANSFER_ATOM, - GetPropertyType::ANY, - 0, - u32::MAX, - )?.reply()?; + Event::PropertyNotify(notify) + if (notify.window, notify.state) + == (window.window, Property::NEW_VALUE) => + { + let property = conn + .get_property( + true, + window.window, + TRANSFER_ATOM, + GetPropertyType::ANY, + 0, + u32::MAX, + )? + .reply()?; if property.value.is_empty() { // End of transfer return Ok(Some(value)); } else { value.extend_from_slice(&property.value); } - }, + } event => self.event_queue.borrow_mut().push_back(event), } } - } } }