JVO3ABY7VTFBUPUEPNXVSGWLCBJLPDHLSLZJEW2LSEOFUR5Z4RIAC
let (_, _, x, y, _, _, _) = display.query_pointer();
let (width, height) = {
let screen = display.default_screen_of_display();
(screen.width, screen.height)
};
let (x, y) = display.query_pointer();
let (width, height) = display.query_screen();
let root = self.display.default_root_window();
self.display.hide_cursor(root);
self.display.grab_pointer(root, true,
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, 0, 0, CurrentTime);
self.display.hide_cursor();
self.display.grab_pointer(PointerMotionMask | ButtonPressMask | ButtonReleaseMask);
// Structs
Cursor,
Screen,
Time,
Window,
XColor,
// Events
XKeyPressedEvent,
XKeyReleasedEvent,
XButtonPressedEvent,
XButtonReleasedEvent,
XMotionEvent,
XEnterWindowEvent,
XLeaveWindowEvent,
XFocusInEvent,
XFocusOutEvent,
XKeymapEvent,
XExposeEvent,
XGraphicsExposeEvent,
XNoExposeEvent,
XVisibilityEvent,
XCreateWindowEvent,
XDestroyWindowEvent,
XUnmapEvent,
XMapEvent,
XMapRequestEvent,
XReparentEvent,
XConfigureEvent,
XConfigureRequestEvent,
XGravityEvent,
XResizeRequestEvent,
XCirculateEvent,
XCirculateRequestEvent,
XPropertyEvent,
XSelectionClearEvent,
XSelectionRequestEvent,
XSelectionEvent,
XColormapEvent,
XClientMessageEvent,
XMappingEvent,
XGenericEventCookie,
// Masks
XI_DeviceChangedMask,
XI_KeyPressMask,
XI_KeyReleaseMask,
XI_ButtonPressMask,
XI_ButtonReleaseMask,
XI_MotionMask,
XI_EnterMask,
XI_LeaveMask,
XI_FocusInMask,
XI_FocusOutMask,
XI_HierarchyChangedMask,
XI_PropertyEventMask,
XI_RawKeyPressMask,
XI_RawKeyReleaseMask,
XI_RawButtonPressMask,
XI_RawButtonReleaseMask,
XI_RawMotionMask,
XI_TouchBeginMask,
XI_TouchEndMask,
XI_TouchOwnershipChangedMask,
XI_TouchUpdateMask,
XI_RawTouchBeginMask,
XI_RawTouchEndMask,
XI_RawTouchUpdateMask,
XI_BarrierHitMask,
XI_BarrierLeaveMask,
pub fn default_screen_of_display(&self) -> &Screen {
unsafe { &*(self.xlib.XDefaultScreenOfDisplay)(self.display) }
pub fn grab_pointer(&self, event_mask: i64) {
unsafe { (self.xlib.XGrabPointer)(
self.display, self.root, xlib::True, event_mask as u32,
xlib::GrabModeAsync, xlib::GrabModeAsync, 0, 0, xlib::CurrentTime
) };
pub fn grab_pointer(&self, grab_window: Window, owner_events: bool,
event_mask: i64, pointer_mode: i32, keyboard_mode: i32,
confine_to: Window, cursor: Cursor, time: Time)
{
unsafe { (self.xlib.XGrabPointer)(
self.display, grab_window, owner_events as i32, event_mask as u32,
pointer_mode, keyboard_mode, confine_to, cursor, time
) };
pub fn grab_key(&self, keycode: i32, modifiers: u32) {
unsafe { (self.xlib.XGrabKey)(
self.display, keycode, modifiers, self.root, xlib::True,
xlib::GrabModeAsync, xlib::GrabModeAsync)
};
pub fn next_event(&self) -> Event {
let mut event: xlib::XEvent = unsafe { mem::uninitialized() };
unsafe { (self.xlib.XNextEvent)(self.display, &mut event) };
pub fn next_event(&self) -> Option<Event> {
// TODO: Would XEventsQueued with QueuedAlready make more sense?
let num_events = unsafe { (self.xlib.XPending)(self.display) };
if num_events <= 0 {
return None;
}
let event = unsafe {
let mut event = mem::uninitialized();
(self.xlib.XNextEvent)(self.display, &mut event);
event
};
let root = self.default_root_window();
let mut root_return: Window = mem::uninitialized();
let mut child_return: Window = mem::uninitialized();
let mut root_x: i32 = mem::uninitialized();
let mut root_y: i32 = mem::uninitialized();
let mut child_x: i32 = mem::uninitialized();
let mut child_y: i32 = mem::uninitialized();
let mut mask: u32 = mem::uninitialized();
let mut root = mem::uninitialized();
let mut child = mem::uninitialized();
let mut root_x = mem::uninitialized();
let mut root_y = mem::uninitialized();
let mut child_x = mem::uninitialized();
let mut child_y = mem::uninitialized();
let mut mask = mem::uninitialized();
pub fn select_input(&self, w: Window, event_mask: i64) {
unsafe { (self.xlib.XSelectInput)(self.display, w, event_mask) };
pub fn query_screen(&self) -> (i32, i32) {
let screen = unsafe {
&*(self.xlib.XDefaultScreenOfDisplay)(self.display)
};
(screen.width, screen.height)
}
pub fn select_input(&self, event_mask: i64) {
unsafe { (self.xlib.XSelectInput)(self.display, self.root, event_mask) };
pub fn xi_select_events(&self, win: Window, mask: &mut [XIEventMask]) {
unsafe { (self.xinput2.XISelectEvents)(self.display, win, &mut mask[0] as *mut XIEventMask, mask.len() as i32) };
pub fn xi_select_events(&self, mask: &mut [XIEventMask]) {
unsafe { (self.xinput2.XISelectEvents)(
self.display, self.root,
&mut mask[0] as *mut XIEventMask, mask.len() as i32
) };
KeyPress(xlib::XKeyPressedEvent),
KeyRelease(xlib::XKeyReleasedEvent),
ButtonPress(xlib::XButtonPressedEvent),
ButtonRelease(xlib::XButtonReleasedEvent),
MotionNotify(xlib::XMotionEvent),
EnterNotify(xlib::XEnterWindowEvent),
LeaveNotify(xlib::XLeaveWindowEvent),
FocusIn(xlib::XFocusInEvent),
FocusOut(xlib::XFocusOutEvent),
KeymapNotify(xlib::XKeymapEvent),
Expose(xlib::XExposeEvent),
GraphicsExpose(xlib::XGraphicsExposeEvent),
NoExpose(xlib::XNoExposeEvent),
VisibilityNotify(xlib::XVisibilityEvent),
CreateNotify(xlib::XCreateWindowEvent),
DestroyNotify(xlib::XDestroyWindowEvent),
UnmapNotify(xlib::XUnmapEvent),
MapNotify(xlib::XMapEvent),
MapRequest(xlib::XMapRequestEvent),
ReparentNotify(xlib::XReparentEvent),
ConfigureNotify(xlib::XConfigureEvent),
ConfigureRequest(xlib::XConfigureRequestEvent),
GravityNotify(xlib::XGravityEvent),
ResizeRequest(xlib::XResizeRequestEvent),
CirculateNotify(xlib::XCirculateEvent),
CirculateRequest(xlib::XCirculateRequestEvent),
PropertyNotify(xlib::XPropertyEvent),
SelectionClear(xlib::XSelectionClearEvent),
SelectionRequest(xlib::XSelectionRequestEvent),
SelectionNotify(xlib::XSelectionEvent),
ColormapNotify(xlib::XColormapEvent),
ClientMessage(xlib::XClientMessageEvent),
MappingNotify(xlib::XMappingEvent),
GenericEvent(xlib::XGenericEventCookie),
KeyPress(XKeyPressedEvent),
KeyRelease(XKeyReleasedEvent),
ButtonPress(XButtonPressedEvent),
ButtonRelease(XButtonReleasedEvent),
MotionNotify(XMotionEvent),
EnterNotify(XEnterWindowEvent),
LeaveNotify(XLeaveWindowEvent),
FocusIn(XFocusInEvent),
FocusOut(XFocusOutEvent),
KeymapNotify(XKeymapEvent),
Expose(XExposeEvent),
GraphicsExpose(XGraphicsExposeEvent),
NoExpose(XNoExposeEvent),
VisibilityNotify(XVisibilityEvent),
CreateNotify(XCreateWindowEvent),
DestroyNotify(XDestroyWindowEvent),
UnmapNotify(XUnmapEvent),
MapNotify(XMapEvent),
MapRequest(XMapRequestEvent),
ReparentNotify(XReparentEvent),
ConfigureNotify(XConfigureEvent),
ConfigureRequest(XConfigureRequestEvent),
GravityNotify(XGravityEvent),
ResizeRequest(XResizeRequestEvent),
CirculateNotify(XCirculateEvent),
CirculateRequest(XCirculateRequestEvent),
PropertyNotify(XPropertyEvent),
SelectionClear(XSelectionClearEvent),
SelectionRequest(XSelectionRequestEvent),
SelectionNotify(XSelectionEvent),
ColormapNotify(XColormapEvent),
ClientMessage(XClientMessageEvent),
MappingNotify(XMappingEvent),
GenericEvent(XGenericEventCookie),