Take an option of a seat name or use name of latest seat event
This commit is contained in:
parent
bd004e8628
commit
61ac558555
2 changed files with 82 additions and 57 deletions
|
|
@ -6,7 +6,7 @@ use sctk::utils::{DoubleMemPool, MemPool};
|
|||
use sctk::window::{ConceptFrame, Event as WEvent, Window};
|
||||
use sctk::Environment;
|
||||
|
||||
use sctk::reexports::client::protocol::{wl_seat, wl_shm, wl_surface};
|
||||
use sctk::reexports::client::protocol::{wl_shm, wl_surface};
|
||||
use sctk::reexports::client::{Display, NewProxy};
|
||||
|
||||
use andrew::shapes::rectangle;
|
||||
|
|
@ -21,20 +21,9 @@ fn main() {
|
|||
let mut clipboard = smithay_clipboard::WaylandClipboard::new_threaded(&display);
|
||||
let cb_contents = Arc::new(Mutex::new(String::new()));
|
||||
|
||||
let seat_name = Arc::new(Mutex::new(String::new()));
|
||||
let seat_name_clone = seat_name.clone();
|
||||
let seat = env
|
||||
.manager
|
||||
.instantiate_range(2, 6, move |proxy| {
|
||||
proxy.implement_closure(
|
||||
move |event, _| {
|
||||
if let wl_seat::Event::Name { name } = event {
|
||||
*seat_name_clone.lock().unwrap() = name
|
||||
}
|
||||
},
|
||||
(),
|
||||
)
|
||||
})
|
||||
.instantiate_range(2, 6, NewProxy::implement_dummy)
|
||||
.unwrap();
|
||||
|
||||
let need_redraw = Arc::new(atomic::AtomicBool::new(false));
|
||||
|
|
@ -48,12 +37,11 @@ fn main() {
|
|||
} = event
|
||||
{
|
||||
if text == " " {
|
||||
*cb_contents_clone.lock().unwrap() =
|
||||
dbg!(clipboard.load(seat_name.lock().unwrap().clone()));
|
||||
*cb_contents_clone.lock().unwrap() = dbg!(clipboard.load(None));
|
||||
need_redraw_clone.store(true, atomic::Ordering::Relaxed)
|
||||
} else if text == "s" {
|
||||
clipboard.store(
|
||||
seat_name.lock().unwrap().clone(),
|
||||
None,
|
||||
"This is an example text thats been copied to the wayland clipboard :)"
|
||||
.to_string(),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue