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,10 +383,7 @@ 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 {
warn!("We are unexpectedly the selection owner? Clipboard may be broken!");
} else {
self.handle_new_owner( self.handle_new_owner(
connection, connection,
wm_window, wm_window,
@ -398,6 +392,8 @@ impl<T: SelectionType> SelectionDataImpl for SelectionData<T> {
self.last_selection_timestamp, 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,8 +774,7 @@ 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(),
@ -790,8 +785,7 @@ impl XState {
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:?}");
}; };
}; };