diff --git a/src/bin/easymacroplay.rs b/src/bin/easymacroplay.rs index 24f5663..c2c0039 100644 --- a/src/bin/easymacroplay.rs +++ b/src/bin/easymacroplay.rs @@ -63,35 +63,35 @@ fn get_remote(display_name: Option) -> XDisplay { display } -fn run_instruction(instruction: &str, display: &XDisplay) { +fn run_instruction(instruction: &str, dpy: &XDisplay) { let instruction: Vec<&str> = instruction.split(' ').collect(); match instruction[0] { "Delay" => thread::sleep(Duration::from_millis(instruction[1].parse().unwrap())), - "ButtonPress" => display.send_fake_buttonpress(instruction[1].parse().unwrap()), - "ButtonRelease" => display.send_fake_buttonrelease(instruction[1].parse().unwrap()), - "MotionNotify" => display + "ButtonPress" => dpy.send_fake_buttonpress(instruction[1].parse().unwrap()), + "ButtonRelease" => dpy.send_fake_buttonrelease(instruction[1].parse().unwrap()), + "MotionNotify" => dpy .send_fake_motion_event(instruction[1].parse().unwrap(), instruction[2].parse().unwrap()), - "KeyCodePress" => display.send_fake_keypress_from_code(instruction[1].parse().unwrap()), - "KeyCodeRelease" => display.send_fake_keyrelease_from_code(instruction[1].parse().unwrap()), - "KeySymPress" => display.send_fake_keypress_from_keysym(instruction[1].parse().unwrap()), + "KeyCodePress" => dpy.send_fake_keypress_from_code(instruction[1].parse().unwrap()), + "KeyCodeRelease" => dpy.send_fake_keyrelease_from_code(instruction[1].parse().unwrap()), + "KeySymPress" => dpy.send_fake_keypress_from_keysym(instruction[1].parse().unwrap()), "KeySymRelease" => { - display.send_fake_keyrelease_from_keysym(instruction[1].parse().unwrap()) + dpy.send_fake_keyrelease_from_keysym(instruction[1].parse().unwrap()) } "KeySym" => { let key: Keysym = instruction[1].parse().unwrap(); - display.send_fake_keypress_from_keysym(key); - display.send_fake_keyrelease_from_keysym(key); + dpy.send_fake_keypress_from_keysym(key); + dpy.send_fake_keyrelease_from_keysym(key); } "KeyStrPress" => { - display.send_fake_keypress_from_string(CString::new(instruction[1]).unwrap().as_bytes()) + dpy.send_fake_keypress_from_string(CString::new(instruction[1]).unwrap().as_bytes()) } - "KeyStrRelease" => display + "KeyStrRelease" => dpy .send_fake_keyrelease_from_string(CString::new(instruction[1]).unwrap().as_bytes()), "KeyStr" => { let keystring = CString::new(instruction[1]).unwrap(); - display.send_fake_keypress_from_string(keystring.as_bytes()); - display.send_fake_keyrelease_from_string(keystring.as_bytes()); + dpy.send_fake_keypress_from_string(keystring.as_bytes()); + dpy.send_fake_keyrelease_from_string(keystring.as_bytes()); } "String" => { println!("Strings are currently not supported."); diff --git a/src/x11_safe_wrapper.rs b/src/x11_safe_wrapper.rs index 376e279..583869e 100644 --- a/src/x11_safe_wrapper.rs +++ b/src/x11_safe_wrapper.rs @@ -1,9 +1,8 @@ -use std::cell::{Ref, RefCell}; use std::env; use std::ffi::{CStr, CString}; use std::os::raw::{c_char, c_int, c_uchar, c_uint, c_ulong}; -use x11::xlib::{Display, GenericEvent, KeyCode, KeyPress, MotionNotify, Status, Time, Window, XAllowEvents, XAnyEvent, XCloseDisplay, XDefaultScreen, XEvent, XFlush, XGrabKeyboard, XID, XKeycodeToKeysym, XKeyEvent, XKeysymToKeycode, XKeysymToString, XOpenDisplay, XQueryPointer, XRootWindow, XStringToKeysym, XSync, XUngrabKeyboard, XUngrabPointer, XWindowEvent}; -use x11::xrecord::{XRecordAllClients, XRecordAllocRange, XRecordClientInfo, XRecordClientSpec, XRecordContext, XRecordCreateContext, XRecordDisableContext, XRecordEnableContext, XRecordEnableContextAsync, XRecordFreeContext, XRecordInterceptData, XRecordProcessReplies, XRecordQueryVersion, XRecordRange}; +use x11::xlib::{Display, GenericEvent, KeyPress, MotionNotify, Time, Window, XAllowEvents, XCloseDisplay, XDefaultScreen, XEvent, XFlush, XGrabKeyboard, XKeycodeToKeysym, XKeysymToKeycode, XKeysymToString, XOpenDisplay, XQueryPointer, XRootWindow, XStringToKeysym, XSync, XUngrabKeyboard, XUngrabPointer, XWindowEvent}; +use x11::xrecord::{XRecordAllClients, XRecordClientSpec, XRecordContext, XRecordCreateContext, XRecordDisableContext, XRecordEnableContext, XRecordEnableContextAsync, XRecordFreeContext, XRecordInterceptData, XRecordProcessReplies, XRecordQueryVersion, XRecordRange}; use x11::xtest::{ XTestFakeButtonEvent, XTestFakeKeyEvent, XTestFakeMotionEvent, XTestGrabControl, XTestQueryExtension,