Skip to content

Commit

Permalink
Get rid of all X11 inline checks for reduced syscalls thanks to advic…
Browse files Browse the repository at this point in the history
…e from psychon/x11rb#933 (comment)

Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Aug 3, 2024
1 parent e614426 commit fdcb76d
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions x11/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ fn run() -> Result<(), CliError> {
let mut deduplicator = CopyDeduplication::new()?;

info!("Starting event loop.");
conn.flush()?;
loop {
while let Some(event) = conn.poll_for_event()? {
handle_x11_event(
Expand All @@ -356,6 +355,7 @@ fn run() -> Result<(), CliError> {
&mut last_paste,
)?;
}
conn.flush()?;

trace!("Waiting for event.");
epoll::wait(&epoll, &mut epoll_events, -1)
Expand Down Expand Up @@ -429,8 +429,7 @@ fn handle_x11_event(
target,
property,
},
)?
.check()?;
)?;
Ok(())
};

Expand Down Expand Up @@ -522,8 +521,7 @@ fn handle_x11_event(
utf8_string_atom,
transfer_atom,
x11rb::CURRENT_TIME,
)?
.check()?;
)?;
}
Event::SelectionNotify(event) => {
let Some((state, transfer_atom)) = allocator.get(event.requestor) else {
Expand All @@ -549,8 +547,7 @@ fn handle_x11_event(
targets_atom,
transfer_atom,
x11rb::CURRENT_TIME,
)?
.check()?;
)?;
}
}
State::TargetsRequest { .. } => {
Expand Down Expand Up @@ -661,8 +658,7 @@ fn handle_x11_event(
target,
transfer_atom,
x11rb::CURRENT_TIME,
)?
.check()?;
)?;
}
s @ (State::FastPathPendingSelection { .. } | State::PendingSelection { .. }) => {
let (mime_atom, mime_type, fast_path) = match s {
Expand Down Expand Up @@ -704,8 +700,7 @@ fn handle_x11_event(
targets_atom,
transfer_atom,
x11rb::CURRENT_TIME,
)?
.check()?;
)?;
} else {
warn!("Dropping empty or blank selection.");
}
Expand Down Expand Up @@ -878,7 +873,6 @@ fn handle_paste_event(
}

debug!("Claiming selection ownership.");
conn.set_selection_owner(paste_window, clipboard_atom, x11rb::CURRENT_TIME)?
.check()?;
conn.set_selection_owner(paste_window, clipboard_atom, x11rb::CURRENT_TIME)?;
Ok(())
}

0 comments on commit fdcb76d

Please sign in to comment.