refactor(xstate): rustfmt, clean up some matches

LuckShiba's commit was not formatted with `rustfmt`, so I took the
opportunity to do some additional refactors.

Some bulky match constructions in xstate/selection were made more
compact as well.
This commit is contained in:
En-En 2025-11-01 14:36:22 +00:00 committed by Supreeeme
parent 53d14ead2a
commit 2b754c3bec

View file

@ -304,17 +304,14 @@ impl<T: SelectionType> SelectionDataImpl for SelectionData<T> {
match connection.wait_for_reply(connection.send_request(&x::GetSelectionOwner { match connection.wait_for_reply(connection.send_request(&x::GetSelectionOwner {
selection: self.atom, selection: self.atom,
})) { })) {
Ok(reply) if reply.owner() == wm_window => true,
Ok(reply) => { Ok(reply) => {
if reply.owner() != wm_window { warn!(
warn!( "Could not become owner of {} (owned by {:?})",
"Could not become owner of {} (owned by {:?})", get_atom_name(connection, self.atom),
get_atom_name(connection, self.atom), reply.owner()
reply.owner() );
); false
false
} else {
true
}
} }
Err(e) => { Err(e) => {
warn!( warn!(
@ -386,18 +383,17 @@ impl<T: SelectionType> SelectionDataImpl for SelectionData<T> {
match connection.wait_for_reply(connection.send_request(&x::GetSelectionOwner { match connection.wait_for_reply(connection.send_request(&x::GetSelectionOwner {
selection: self.atom, selection: self.atom,
})) { })) {
Ok(reply) => { Ok(reply) if reply.owner() != wm_window => {
if reply.owner() == wm_window { self.handle_new_owner(
warn!("We are unexpectedly the selection owner? Clipboard may be broken!"); connection,
} else { wm_window,
self.handle_new_owner( atoms,
connection, reply.owner(),
wm_window, self.last_selection_timestamp,
atoms, );
reply.owner(), }
self.last_selection_timestamp, Ok(_) => {
); warn!("We are unexpectedly the selection owner? Clipboard may be broken!");
}
} }
Err(e) => { Err(e) => {
error!("Couldn't grab selection owner: {e:?}. Clipboard is stale!"); error!("Couldn't grab selection owner: {e:?}. Clipboard is stale!");
@ -778,20 +774,18 @@ impl XState {
xcb::Event::X(x::Event::SelectionRequest(e)) => { xcb::Event::X(x::Event::SelectionRequest(e)) => {
let data = get_selection_data!(e.selection()); let data = get_selection_data!(e.selection());
let send_notify = |property| { let send_notify = |property| {
let result = self.connection if let Err(e) = self.connection.send_and_check_request(&x::SendEvent {
.send_and_check_request(&x::SendEvent { propagate: false,
propagate: false, destination: x::SendEventDest::Window(e.requestor()),
destination: x::SendEventDest::Window(e.requestor()), event_mask: x::EventMask::empty(),
event_mask: x::EventMask::empty(), event: &x::SelectionNotifyEvent::new(
event: &x::SelectionNotifyEvent::new( e.time(),
e.time(), e.requestor(),
e.requestor(), e.selection(),
e.selection(), e.target(),
e.target(), property,
property, ),
), }) {
});
if let Err(e) = result {
warn!("Failed to send selection request notify: {e:?}"); warn!("Failed to send selection request notify: {e:?}");
}; };
}; };