diff --git a/Cargo.lock b/Cargo.lock index 2066f6be..1527727a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -177,7 +177,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a22a6a8f622f797120d452c630b0ab12e1331a1a753e2039ce7868d4ac77b4ee" dependencies = [ "log", - "nix 0.24.1", + "nix 0.24.2", "slotmap", "thiserror", "vec_map", @@ -402,9 +402,9 @@ dependencies = [ [[package]] name = "crypto-common" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ccfd8c0ee4cce11e45b3fd6f9d5e69e0cc62912aa6a0cb1bf4617b0eba5a12f" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", @@ -719,9 +719,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" [[package]] name = "gl_generator" @@ -736,9 +736,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "607c8a29735385251a339424dd462993c0fed8fa09d378f259377df08c126022" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hermit-abi" @@ -1071,9 +1071,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f17df307904acd05aa8e32e97bb20f2a0df1728bbc2d771ae8f9a90463441e9" +checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" dependencies = [ "bitflags", "cfg-if 1.0.0", @@ -1367,9 +1367,9 @@ checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" [[package]] name = "rustversion" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0a5f7c728f5d284929a1cccb5bc19884422bfe6ef4d6c409da2c41838983fcf" +checksum = "24c8ad4f0c00e1eb5bc7614d236a7f1300e3dbd76b68cac8e06fb00b015ad8d8" [[package]] name = "ryu" @@ -1729,9 +1729,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" [[package]] name = "uuid" @@ -1823,7 +1823,7 @@ dependencies = [ "cc", "downcast-rs", "log", - "nix 0.24.1", + "nix 0.24.2", "scoped-tls", "smallvec", "wayland-sys 0.30.0-beta.7", @@ -1855,7 +1855,7 @@ dependencies = [ "futures-channel", "futures-core", "log", - "nix 0.24.1", + "nix 0.24.2", "thiserror", "wayland-backend", "wayland-scanner 0.30.0-beta.7", @@ -1965,7 +1965,7 @@ dependencies = [ "bitflags", "downcast-rs", "log", - "nix 0.24.1", + "nix 0.24.2", "thiserror", "wayland-backend", "wayland-scanner 0.30.0-beta.7", @@ -2130,7 +2130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507" dependencies = [ "gethostname", - "nix 0.24.1", + "nix 0.24.2", "winapi", "winapi-wsapoll", "x11rb-protocol", @@ -2142,7 +2142,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67" dependencies = [ - "nix 0.24.1", + "nix 0.24.2", ] [[package]] diff --git a/src/input/mod.rs b/src/input/mod.rs index fc10051c..b8150b15 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -16,6 +16,7 @@ use smithay::{ wayland::{ data_device::set_data_device_focus, output::Output, + primary_selection::set_primary_focus, seat::{ keysyms, ButtonEvent, CursorImageStatus, FilterResult, KeysymHandle, MotionEvent, Seat, XkbConfig, @@ -126,6 +127,8 @@ pub fn add_seat(dh: &DisplayHandle, name: String) -> Seat { focus.and_then(|s| dh_clone.get_client(s.id()).ok()) { set_data_device_focus(&dh_clone, seat, Some(client)); + let client2 = focus.and_then(|s| dh_clone.get_client(s.id()).ok()).unwrap(); + set_primary_focus(&dh_clone, seat, Some(client2)) } }, ); diff --git a/src/state.rs b/src/state.rs index 31c2bc02..46d4b6e8 100644 --- a/src/state.rs +++ b/src/state.rs @@ -24,6 +24,7 @@ use smithay::{ data_device::DataDeviceState, dmabuf::DmabufState, output::{Mode as OutputMode, Output, OutputManagerState, Scale}, + primary_selection::PrimarySelectionState, seat::{Seat, SeatState}, shm::ShmState, viewporter::ViewporterState, @@ -86,6 +87,7 @@ pub struct Common { pub dmabuf_state: DmabufState, pub output_state: OutputManagerState, pub output_configuration_state: OutputConfigurationState, + pub primary_selection_state: PrimarySelectionState, pub seat_state: SeatState, pub shm_state: ShmState, pub wl_drm_state: WlDrmState, @@ -213,6 +215,7 @@ impl State { let dmabuf_state = DmabufState::new(); let output_state = OutputManagerState::new_with_xdg_output::(dh); let output_configuration_state = OutputConfigurationState::new(dh, |_| true); + let primary_selection_state = PrimarySelectionState::new::(dh, None); let shm_state = ShmState::new::(dh, vec![], None); let seat_state = SeatState::::new(); let viewporter_state = ViewporterState::new::(dh, None); @@ -264,6 +267,7 @@ impl State { seat_state, output_state, output_configuration_state, + primary_selection_state, viewporter_state, wl_drm_state, }, diff --git a/src/wayland/handlers/mod.rs b/src/wayland/handlers/mod.rs index c22de5a1..588521e9 100644 --- a/src/wayland/handlers/mod.rs +++ b/src/wayland/handlers/mod.rs @@ -7,6 +7,7 @@ pub mod dmabuf; pub mod layer_shell; pub mod output; pub mod output_configuration; +pub mod primary_selection; pub mod seat; pub mod shm; pub mod toplevel_info; diff --git a/src/wayland/handlers/primary_selection.rs b/src/wayland/handlers/primary_selection.rs new file mode 100644 index 00000000..d77b2264 --- /dev/null +++ b/src/wayland/handlers/primary_selection.rs @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-3.0-only + +use crate::state::State; +use smithay::{ + delegate_primary_selection, + wayland::primary_selection::{PrimarySelectionHandler, PrimarySelectionState}, +}; + +impl PrimarySelectionHandler for State { + fn primary_selection_state(&self) -> &PrimarySelectionState { + &self.common.primary_selection_state + } +} + +delegate_primary_selection!(State);