diff --git a/Cargo.toml b/Cargo.toml index 6270890..ac9085e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,9 @@ name = "clipboard" version = "0.0.1" authors = ["Avi Weinstock "] -[dependencies.xlib] -git = "https://github.com/servo/rust-xlib" +[dependencies.x11] +version = "1.1.0" +features = ["xlib", "xmu"] [dependencies] libc = "*" diff --git a/src/lib.rs b/src/lib.rs index 78e47d5..c5973ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ #[cfg(target_os="linux")] extern crate libc; #[cfg(target_os="linux")] -extern crate xlib; +extern crate x11; #[cfg(target_os="linux")] mod x11_clipboard; diff --git a/src/x11_clipboard.rs b/src/x11_clipboard.rs index 0cdbe09..3ed5c6c 100644 --- a/src/x11_clipboard.rs +++ b/src/x11_clipboard.rs @@ -1,7 +1,8 @@ -use std::mem::{size_of, transmute}; +use std::mem::{size_of, transmute, zeroed}; use libc::*; -use xlib::*; +use x11::xlib::*; +use x11::xmu::*; use std::{ptr,slice}; @@ -23,7 +24,7 @@ impl ClipboardContext { if win == 0 { return Err("XCreateSimpleWindow") } - if unsafe { XSelectInput(dpy, win, PropertyChangeMask.bits()) } == 0 { + if unsafe { XSelectInput(dpy, win, PropertyChangeMask) } == 0 { return Err("XSelectInput"); } let sel = unsafe { XmuInternAtom(dpy, _XA_CLIPBOARD) }; @@ -75,7 +76,7 @@ impl ClipboardContext { }, XCOutState::SentConvSel => { let event: &mut XSelectionEvent = unsafe { transmute(evt) }; - if event._type != SelectionNotify { + if event.type_ != SelectionNotify { return; } if event.property == 0 { @@ -83,7 +84,7 @@ impl ClipboardContext { return; } unsafe { - XGetWindowProperty(dpy, win, pty_atom, 0, 0, 0, 0, type_, + XGetWindowProperty(dpy, win, pty_atom, 0, 0, 0, 0, type_, &mut pty_format, &mut pty_items, &mut pty_size, &mut buffer); XFree(buffer as *mut c_void); @@ -97,7 +98,7 @@ impl ClipboardContext { return; } unsafe { - XGetWindowProperty(dpy, win, pty_atom, 0, pty_size as c_long, 0, 0, type_, + XGetWindowProperty(dpy, win, pty_atom, 0, pty_size as c_long, 0, 0, type_, &mut pty_format, &mut pty_items, &mut pty_size, &mut buffer); } @@ -108,14 +109,14 @@ impl ClipboardContext { XCOutState::BadTarget => panic!("should be unreachable"), XCOutState::Incr => { let event: &mut XPropertyEvent = unsafe { transmute(evt) }; - if event._type != PropertyNotify { + if event.type_ != PropertyNotify { return; } if event.state != 0 { // 0 == PropertyNewValue return; } unsafe { - XGetWindowProperty(dpy, win, pty_atom, 0, 0, 0, 0, type_, + XGetWindowProperty(dpy, win, pty_atom, 0, 0, 0, 0, type_, &mut pty_format, &mut pty_items, &mut pty_size, &mut buffer); XFree(buffer as *mut c_void); @@ -129,7 +130,7 @@ impl ClipboardContext { return; } unsafe { - XGetWindowProperty(dpy, win, pty_atom, 0, pty_size as c_long, 0, 0, type_, + XGetWindowProperty(dpy, win, pty_atom, 0, pty_size as c_long, 0, 0, type_, &mut pty_format, &mut pty_items, &mut pty_size, &mut buffer); } @@ -142,7 +143,7 @@ impl ClipboardContext { let mut sel_buf = vec![]; let mut sel_type = 0; let mut state = XCOutState::None; - let mut event = XEvent { _type: 0, pad: [0; 24] }; + let mut event: XEvent = unsafe { zeroed() }; let mut target = self.utf8string; loop { if let XCOutState::None = state {} else {