1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 06:41:03 +02:00

refactor(clipboard): switch from nix to rustix

This commit is contained in:
Jake Stanger 2025-01-16 23:32:37 +00:00
parent a0231559d0
commit 5bb1c88c12
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
3 changed files with 10 additions and 5 deletions

View file

@ -20,6 +20,7 @@ use std::ffi::c_int;
use std::fmt::{Debug, Formatter}; use std::fmt::{Debug, Formatter};
use std::fs::File; use std::fs::File;
use std::io::{ErrorKind, Write}; use std::io::{ErrorKind, Write};
use std::os::fd::RawFd;
use std::os::fd::{AsFd, BorrowedFd, OwnedFd}; use std::os::fd::{AsFd, BorrowedFd, OwnedFd};
use std::sync::Arc; use std::sync::Arc;
use std::{fs, io}; use std::{fs, io};
@ -156,7 +157,7 @@ impl Environment {
let source = self let source = self
.data_control_device_manager_state .data_control_device_manager_state
.create_copy_paste_source(&self.queue_handle, [&item.mime_type, INTERNAL_MIME_TYPE]); .create_copy_paste_source(&self.queue_handle, [INTERNAL_MIME_TYPE, &item.mime_type]);
source.set_selection(&device.device); source.set_selection(&device.device);
self.copy_paste_sources.push(source); self.copy_paste_sources.push(source);
@ -331,7 +332,7 @@ impl DataControlSourceHandler for Environment {
debug!("Done writing"); debug!("Done writing");
} else { } else {
error!("Failed to find source (mime: '{mime}')"); error!("Failed to find source");
} }
} }

View file

@ -1,6 +1,6 @@
use super::manager::DataControlDeviceManagerState; use super::manager::DataControlDeviceManagerState;
use crate::lock; use crate::lock;
use rustix::pipe::{PipeFlags, pipe_with}; use rustix::pipe::{pipe_with, PipeFlags};
use smithay_client_toolkit::data_device_manager::data_offer::DataOfferError; use smithay_client_toolkit::data_device_manager::data_offer::DataOfferError;
use std::ops::DerefMut; use std::ops::DerefMut;
use std::os::fd::AsFd; use std::os::fd::AsFd;

View file

@ -1,6 +1,8 @@
use super::device::DataControlDevice; use super::device::DataControlDevice;
use super::manager::DataControlDeviceManagerState; use super::manager::DataControlDeviceManagerState;
use color_eyre::Result;
use smithay_client_toolkit::data_device_manager::WritePipe; use smithay_client_toolkit::data_device_manager::WritePipe;
use tracing::error;
use wayland_client::{Connection, Dispatch, Proxy, QueueHandle}; use wayland_client::{Connection, Dispatch, Proxy, QueueHandle};
use wayland_protocols_wlr::data_control::v1::client::zwlr_data_control_source_v1::{ use wayland_protocols_wlr::data_control::v1::client::zwlr_data_control_source_v1::{
Event, ZwlrDataControlSourceV1, Event, ZwlrDataControlSourceV1,
@ -41,7 +43,7 @@ pub trait DataControlSourceHandler: Sized {
source: &ZwlrDataControlSourceV1, source: &ZwlrDataControlSourceV1,
mime: String, mime: String,
fd: WritePipe, fd: WritePipe,
); ) -> Result<()>;
/// The data source is no longer valid /// The data source is no longer valid
/// Cleanup & destroy this resource /// Cleanup & destroy this resource
@ -68,7 +70,9 @@ where
) { ) {
match event { match event {
Event::Send { mime_type, fd } => { Event::Send { mime_type, fd } => {
state.send_request(conn, qh, source, mime_type, fd.into()); if let Err(err) = state.send_request(conn, qh, source, mime_type, fd.into()) {
error!("{err:#}");
}
} }
Event::Cancelled => { Event::Cancelled => {
state.cancelled(conn, qh, source); state.cancelled(conn, qh, source);