1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-16 22:31:03 +02:00

fix(clipboard): failing to paste in some applications

Fixed by ensuring the internal mime type is always last
This commit is contained in:
Jake Stanger 2025-01-16 23:33:02 +00:00
parent 5bb1c88c12
commit ff9ba7b5f5
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
4 changed files with 59 additions and 76 deletions

110
Cargo.lock generated
View file

@ -130,7 +130,7 @@ dependencies = [
"futures-lite", "futures-lite",
"parking", "parking",
"polling", "polling",
"rustix", "rustix 0.38.44",
"slab", "slab",
"tracing", "tracing",
"windows-sys 0.59.0", "windows-sys 0.59.0",
@ -321,7 +321,7 @@ dependencies = [
"bitflags 2.9.0", "bitflags 2.9.0",
"log", "log",
"polling", "polling",
"rustix", "rustix 0.38.44",
"slab", "slab",
"thiserror 1.0.69", "thiserror 1.0.69",
] ]
@ -333,7 +333,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02"
dependencies = [ dependencies = [
"calloop", "calloop",
"rustix", "rustix 0.38.44",
"wayland-backend", "wayland-backend",
"wayland-client", "wayland-client",
] ]
@ -394,9 +394,9 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.29" version = "4.5.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" checksum = "d8aa86934b44c19c50f87cc2790e19f54f7a67aedb64101c2e1a2e5ecfb73944"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -404,9 +404,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.5.29" version = "4.5.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" checksum = "2414dbb2dd0695280da6ea9261e327479e9d37b0630f6b53ba2a11c60c679fd9"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -476,9 +476,9 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]] [[package]]
name = "colpetto" name = "colpetto"
version = "0.5.1" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc03b5723fbb502f5f7bc5dbc48b04880a22bb0a887bd3da5271fa4811c1e2bc" checksum = "a9bac489a5240c777561cb744407f9fd4b42c5218241ad39c28c6396dcf08c9f"
dependencies = [ dependencies = [
"cc", "cc",
"devil", "devil",
@ -533,30 +533,6 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "crossbeam-deque"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"memoffset 0.8.0",
"scopeguard",
]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.21" version = "0.8.21"
@ -784,12 +760,6 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feeef44e73baff3a26d371801df019877a9866a8c493d315ab00177843314f35" checksum = "feeef44e73baff3a26d371801df019877a9866a8c493d315ab00177843314f35"
[[package]]
name = "either"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]] [[package]]
name = "endi" name = "endi"
version = "1.1.0" version = "1.1.0"
@ -1859,10 +1829,9 @@ dependencies = [
"mpd-utils", "mpd-utils",
"mpris", "mpris",
"notify", "notify",
"pkg-config",
"regex", "regex",
"reqwest", "reqwest",
"rustix", "rustix 1.0.5",
"schemars", "schemars",
"serde", "serde",
"serde_json", "serde_json",
@ -1966,7 +1935,7 @@ version = "2.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "441092fb2d05962d74246a00c1b2f8c87c60fb6b38a5cc42227c229a702c0ce5" checksum = "441092fb2d05962d74246a00c1b2f8c87c60fb6b38a5cc42227c229a702c0ce5"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 2.9.0",
"libc", "libc",
"libpulse-sys", "libpulse-sys",
"num-derive", "num-derive",
@ -2004,6 +1973,12 @@ version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
[[package]]
name = "linux-raw-sys"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413"
[[package]] [[package]]
name = "litemap" name = "litemap"
version = "0.7.5" version = "0.7.5"
@ -2262,8 +2237,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.38", "quote 1.0.39",
"syn 1.0.109", "syn 2.0.99",
] ]
[[package]] [[package]]
@ -2281,7 +2256,7 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daeaf60f25471d26948a1c2f840e3f7d86f4109e3af4e8e4b5cd70c39690d925" checksum = "daeaf60f25471d26948a1c2f840e3f7d86f4109e3af4e8e4b5cd70c39690d925"
dependencies = [ dependencies = [
"bitflags 2.7.0", "bitflags 2.9.0",
] ]
[[package]] [[package]]
@ -2507,7 +2482,7 @@ dependencies = [
"concurrent-queue", "concurrent-queue",
"hermit-abi", "hermit-abi",
"pin-project-lite", "pin-project-lite",
"rustix", "rustix 0.38.44",
"tracing", "tracing",
"windows-sys 0.59.0", "windows-sys 0.59.0",
] ]
@ -2782,7 +2757,20 @@ dependencies = [
"bitflags 2.9.0", "bitflags 2.9.0",
"errno", "errno",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys 0.4.15",
"windows-sys 0.59.0",
]
[[package]]
name = "rustix"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf"
dependencies = [
"bitflags 2.9.0",
"errno",
"libc",
"linux-raw-sys 0.9.3",
"windows-sys 0.59.0", "windows-sys 0.59.0",
] ]
@ -2825,6 +2813,12 @@ dependencies = [
"untrusted", "untrusted",
] ]
[[package]]
name = "rustversion"
version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.19" version = "1.0.19"
@ -2873,18 +2867,6 @@ dependencies = [
"syn 2.0.99", "syn 2.0.99",
] ]
[[package]]
name = "scoped-tls"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "2.11.1" version = "2.11.1"
@ -3065,7 +3047,7 @@ dependencies = [
"libc", "libc",
"log", "log",
"memmap2", "memmap2",
"rustix", "rustix 0.38.44",
"thiserror 1.0.69", "thiserror 1.0.69",
"wayland-backend", "wayland-backend",
"wayland-client", "wayland-client",
@ -3284,7 +3266,7 @@ dependencies = [
"fastrand", "fastrand",
"getrandom 0.3.1", "getrandom 0.3.1",
"once_cell", "once_cell",
"rustix", "rustix 0.38.44",
"windows-sys 0.59.0", "windows-sys 0.59.0",
] ]
@ -3867,7 +3849,7 @@ checksum = "b7208998eaa3870dad37ec8836979581506e0c5c64c20c9e79e9d2a10d6f47bf"
dependencies = [ dependencies = [
"cc", "cc",
"downcast-rs", "downcast-rs",
"rustix", "rustix 0.38.44",
"smallvec", "smallvec",
"wayland-sys", "wayland-sys",
] ]
@ -3879,7 +3861,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2120de3d33638aaef5b9f4472bff75f07c56379cf76ea320bd3a3d65ecaf73f" checksum = "c2120de3d33638aaef5b9f4472bff75f07c56379cf76ea320bd3a3d65ecaf73f"
dependencies = [ dependencies = [
"bitflags 2.9.0", "bitflags 2.9.0",
"rustix", "rustix 0.38.44",
"wayland-backend", "wayland-backend",
"wayland-scanner", "wayland-scanner",
] ]
@ -3901,7 +3883,7 @@ version = "0.31.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a93029cbb6650748881a00e4922b076092a6a08c11e7fbdb923f064b23968c5d" checksum = "a93029cbb6650748881a00e4922b076092a6a08c11e7fbdb923f064b23968c5d"
dependencies = [ dependencies = [
"rustix", "rustix 0.38.44",
"wayland-client", "wayland-client",
"xcursor", "xcursor",
] ]

View file

@ -178,7 +178,7 @@ futures-lite = { version = "2.6.0", optional = true } # network_manager, upower,
zbus = { version = "5.5.0", default-features = false, features = ["tokio"], optional = true } # network_manager, notifications, upower zbus = { version = "5.5.0", default-features = false, features = ["tokio"], optional = true } # network_manager, notifications, upower
swayipc-async = { version = "2.0.4", optional = true } # workspaces, keyboard swayipc-async = { version = "2.0.4", optional = true } # workspaces, keyboard
hyprland = { version = "0.4.0-alpha.3", features = ["silent"], optional = true } # workspaces, keyboard hyprland = { version = "0.4.0-alpha.3", features = ["silent"], optional = true } # workspaces, keyboard
rustix = { version = "0.38.43", default-features = false, features = ["fs", "pipe"], optional = true } # clipboard, input rustix = { version = "1.0.5", default-features = false, features = ["std", "fs", "pipe", "event"], optional = true } # clipboard, input
# schema # schema
schemars = { version = "0.8.22", optional = true } schemars = { version = "0.8.22", optional = true }
@ -188,7 +188,3 @@ clap = { version = "4.5.34", features = ["derive"] }
clap_complete = "4.5.47" clap_complete = "4.5.47"
serde = { version = "1.0.219", features = ["derive"] } serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140" serde_json = "1.0.140"
pkg-config = "0.3.31" # specify version to fix dep resolution issue
#[patch.crates-io]
#system-tray = { path = "../system-tray" }

View file

@ -11,18 +11,19 @@ use crate::{Ironbar, lock, spawn, try_send};
use color_eyre::Result; use color_eyre::Result;
use device::DataControlDevice; use device::DataControlDevice;
use glib::Bytes; use glib::Bytes;
use rustix::buffer::spare_capacity;
use rustix::event::epoll; use rustix::event::epoll;
use rustix::event::epoll::CreateFlags; use rustix::event::epoll::CreateFlags;
use rustix::fs::Timespec;
use rustix::pipe::{fcntl_getpipe_size, fcntl_setpipe_size}; use rustix::pipe::{fcntl_getpipe_size, fcntl_setpipe_size};
use smithay_client_toolkit::data_device_manager::WritePipe; use smithay_client_toolkit::data_device_manager::WritePipe;
use std::cmp::min; use std::cmp::min;
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::time::Duration;
use std::{fs, io}; use std::{fs, io};
use tokio::io::AsyncReadExt; use tokio::io::AsyncReadExt;
use tokio::sync::broadcast; use tokio::sync::broadcast;
@ -157,7 +158,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, [INTERNAL_MIME_TYPE, &item.mime_type]); .create_copy_paste_source(&self.queue_handle, [&item.mime_type, INTERNAL_MIME_TYPE]);
source.set_selection(&device.device); source.set_selection(&device.device);
self.copy_paste_sources.push(source); self.copy_paste_sources.push(source);
@ -311,12 +312,16 @@ impl DataControlSourceHandler for Environment {
epoll::EventFlags::OUT, epoll::EventFlags::OUT,
)?; )?;
let mut events = epoll::EventVec::with_capacity(16); let mut events = Vec::with_capacity(16);
while !bytes.is_empty() { while !bytes.is_empty() {
let chunk = &bytes[..min(pipe_size, bytes.len())]; let chunk = &bytes[..min(pipe_size, bytes.len())];
epoll::wait(&epoll, &mut events, 100u16 as c_int)?; epoll::wait(
&epoll,
spare_capacity(&mut events),
Some(&Timespec::try_from(Duration::from_millis(100))?),
)?;
match file.write(chunk) { match file.write(chunk) {
Ok(written) => { Ok(written) => {
@ -332,7 +337,7 @@ impl DataControlSourceHandler for Environment {
debug!("Done writing"); debug!("Done writing");
} else { } else {
error!("Failed to find source"); error!("Failed to find source (mime: '{mime}')");
} }
} }

View file

@ -1,6 +1,6 @@
use super::manager::DataControlDeviceManagerState; use super::manager::DataControlDeviceManagerState;
use crate::lock; use crate::lock;
use rustix::pipe::{pipe_with, PipeFlags}; use rustix::pipe::{PipeFlags, pipe_with};
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;